home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / dd / dasm.asm < prev    next >
Assembly Source File  |  1994-02-06  |  59KB  |  2,836 lines

  1. ;         CSYMFMT
  2.  
  3. ;         objfile "dasm.o"
  4. ;         addsym
  5.  
  6.     IFD BARFLY
  7.         BOPT    h-,l-,a+,f+,O-,wo-,ws-
  8.         SUPER
  9.     ENDC
  10.  
  11.  
  12.  
  13. ; move #$2700,SR
  14. ; 91c8 suba.l a0,a0
  15.  
  16. ******************** ********************************************************
  17. ******************** ********************************************************
  18. ******************** ********************************************************
  19. ***                                      ***
  20. ***            DASM  : A 680x0 Disassembler              ***
  21. ***            Programmed by Mike Schwartz              ***
  22. ***            (c)1988, Midnight Oil Software, Inc.          ***
  23. ***            680x0 Enhancements by Brett Bourbin          ***
  24. ***            (c)1992, Selgus Limited.              ***
  25. ***                                      ***
  26. ******************** ********************************************************
  27. ******************** ********************************************************
  28. ******************** ********************************************************
  29.  
  30. ****
  31. **** This disassembler provides symbolic capabilities.    It expects whatever
  32. **** program that calls it to provide a 'C' callable subroutine to do the
  33. **** symbol lookup.  It should be of the form:
  34. ****    name = LookupValue(value);
  35. ****    char    *name;    value;
  36. **** Obviously, the routine looks for value in a symbol table and returns
  37. **** a pointer to a null-terminated character string that contains the
  38. **** name associated with the symbol.  If no symbolic debugging information
  39. **** is desired, the caller must provide a routine along the following:
  40. ****    long    LookupValue() { return 0L; }
  41. ****
  42.  
  43.         XREF        _LookupValue
  44.  
  45. ;
  46. ; For development purposes, defining MAKESYMBOLS causes MANX to put
  47. ; symbols in the library.
  48. ;
  49. MAKESYMBOLS    EQU    1
  50.  
  51. SYMBOL        MACRO
  52.         IFD    MAKESYMBOLS
  53.         XDEF    \1
  54.         ENDC
  55.         ENDM
  56.  
  57. ;
  58. ; size = Disassemble(memptr, pc, outbuf)
  59. ; short     size;        size of instruction in bytes
  60. ; UWORD     *memptr;    address in memory to disassemble
  61. ; ULONG     pc;        program counter where instruction resides
  62. ; char        *outbuf;    buffer to store disassembled string
  63. ;
  64. ; Synopsis:
  65. ;    This routine disassembles one instruction from the supplied
  66. ;    buffer (memptr) and formats it into ascii suitable for printing
  67. ;    in the caller's buffer (outbuf).  The instruction is assumed to
  68. ;    be located at the address specified by the program counter (pc)
  69. ;    parameter.
  70. ;
  71. ; These registers always contain these values:
  72. ;    a6 = output buffer index
  73. ;    a5 = ptr to 'C' parameters
  74. ;    a0 = ptr to instruction, postwords...
  75. ;    d7 = program counter
  76. ;    d6 = instruction size (in bytes)
  77. ;    d4 = EA Register (0-7)
  78. ;    d3 = EA Mode (0-7)
  79. ;    d2 = instruction size (0 = byte, 4 = word, 8 = long)
  80. ;    d1 = instruction word
  81.  
  82.  
  83. * SCRATCH0    EQUR        D0
  84. * INSTRUCTION    EQUR        D1
  85. * OPSIZE        EQUR        D2
  86. * EAMODE        EQUR        D3
  87. * EAREGISTER    EQUR        D4
  88. * SCRATCH1    EQUR        D5
  89. * BYTESIZE    EQUR        D6
  90. * PROGRAMCOUNTER    EQUR        D7
  91. * MEMPTR        EQUR        A0
  92. * PTR        EQUR        A1
  93. * PARAMS        EQUR        A5
  94. * OUTBUF        EQUR        A6
  95.  
  96.         SYMBOL        OpCodeMap
  97. OpCodeMap    dc.l        Group0
  98.         dc.l        Group1
  99.         dc.l        Group2
  100.         dc.l        Group3
  101.         dc.l        Group4
  102.         dc.l        Group5
  103.         dc.l        Group6
  104.         dc.l        Group7
  105.         dc.l        Group8
  106.         dc.l        Group9
  107.         dc.l        Group10
  108.         dc.l        Group11
  109.         dc.l        Group12
  110.         dc.l        Group13
  111.         dc.l        Group14
  112.         dc.l        Group15
  113.  
  114. dregs        REG        d2-d7/a3-a6
  115.  
  116.         XDEF        _Disassemble
  117. _Disassemble    link        A5,#0
  118.         movem.l     dregs,-(sp)
  119.  
  120.         move.l        8(A5),A0    ; ptr to instruction
  121.         move.l        12(A5),D7    ; program counter
  122.         move.l        16(A5),A6    ; output buffer
  123.         moveq.l     #0,D6        ; instruction size (in bytes)
  124.  
  125.         bsr        FetchWord        ; instruction word
  126.         move.w        D0,D1    ;
  127.  
  128.  
  129. ;        bsr        DTab            ; put a tab in outbuf
  130.  
  131.         lea        OpCodeMap,A1        ; lookup table address
  132.         move.w        D1,D0
  133.         asr.w        #8,D0        ; get OpCode (bits 12-15)
  134.         asr.w        #4,D0
  135.         and.w        #$000f,D0    ; for table lookup
  136.         asl.w        #2,D0        ; 4 bytes per table entry
  137.         move.l        0(A1,D0.w),A1    ; fetch decode routine address
  138.         jsr        (A1)               ; and call the routine
  139.  
  140.         move.l        D6,D0        ; return value
  141.         movem.l     (sp)+,dregs
  142.         unlk        A5
  143.         rts
  144.  
  145. ***** Utility Routines
  146.  
  147. ;
  148. ; FetchWord
  149. ;
  150. ; Synopsis:
  151. ;    This routine fetches the next word from memory into D0.w, and
  152. ;    increments the instruction size in D6 by 2.
  153. ;
  154.         SYMBOL        FetchWord
  155. FetchWord    addq        #2,D6        ; instruction is 2 bytes bigger
  156.         move.w        (A0)+,D0
  157.         rts
  158.  
  159. ;
  160. ; FetchLong
  161. ;
  162. ; Synopsis:
  163. ;    This routine fetches the next long from memory into D0.l and
  164. ;    adds 4 to the instruction size in D6.
  165. ;
  166.         SYMBOL        FetchLong
  167. FetchLong    addq        #4,D6
  168.         move.l        (A0)+,D0
  169.         rts
  170.  
  171. ;
  172. ; JumpTable
  173. ; ScaledJumpTable
  174. ;
  175. ; Synopsis:
  176. ;    saves code by doing jump table lookup and jump
  177. ;
  178. ; assumes A1 = jump table address, D0 = jump table entry #
  179. ;                 or D0 = jump table entry # * 4
  180. ;
  181.         SYMBOL        JumpTable
  182. JumpTable    asl.w        #2,D0
  183.         SYMBOL        ScaledJumpTable
  184. ScaledJumpTable:
  185.         move.l        0(A1,D0.w),-(sp)
  186.         rts
  187.  
  188. ;
  189. ; DString
  190. ;
  191. ; Synopsis:
  192. ;    Puts the string pointed to by A1 on the end of the output buffer.
  193. ;
  194.         SYMBOL        DString
  195. DString     move.b        (A1)+,(A6)+
  196.         bne.s        DString
  197.         subq        #1,A6        ; point at null terminator
  198.         rts
  199.  
  200. ;
  201. ; DNull
  202. ;
  203. ; Synopsis:
  204. ;    Puts a NULL in outbuf.
  205. ;
  206. ; NOTE: Does not increment A6 (outbuf ptr) !!!
  207. ;
  208.         SYMBOL        DNull
  209. DNull        clr.b        (A6)
  210.         rts
  211.  
  212. ;
  213. ; DChar
  214. ;
  215. ; Synopsis:
  216. ;    Puts a character from D0.b in output buffer.
  217. ;
  218.         SYMBOL        DChar
  219. DChar        move.b        D0,(A6)+
  220.         bra.s        DNull
  221.  
  222.         SYMBOL        DTab
  223. DTab        move.l        d0,-(sp)
  224. 10$        move.b        #' ',(A6)+
  225.         move.l        A6,d0
  226.         sub.l        16(A5),d0
  227.         and.b        #7,d0
  228.         bne.s        10$
  229.         move.l        (sp)+,d0
  230.         bra.s        DNull
  231.  
  232. ;
  233. ; DHex
  234. ;
  235. ; Synopsis:
  236. ;    Converts the hex digit in D0 (bits 0-3) to a hex ascii character
  237. ;    and puts it in outbuf.
  238. ;
  239.         SYMBOL        DHex
  240. DHex        and.w        #$000f,D0
  241.         lea        hex_string,A1
  242.         move.b        0(A1,D0.w),(A6)+
  243.         bra.s        DNull
  244.  
  245.         SYMBOL        DComma
  246. DComma        move.b        #',',(A6)+
  247.         bra.s        DNull
  248.  
  249.         SYMBOL        DA
  250. DA        move.b        #'A',(A6)+
  251.         bra.s        DNull
  252.  
  253.         SYMBOL        DB
  254. DB        move.b        #'B',(A6)+
  255.         bra.s        DNull
  256.  
  257.         SYMBOL        DD
  258. DD        move.b        #'D',(A6)+
  259.         bra.s        DNull
  260.  
  261.         SYMBOL        DS
  262. DS        move.b        #'S',(A6)+
  263.         bra.s        DNull
  264.  
  265.         SYMBOL        DZ
  266. DZ        move.b        #'Z',(A6)+  ; output a Z
  267.         bra.s        DNull
  268.  
  269.         SYMBOL        DOpen
  270. DOpen        move.b        #'(',(A6)+
  271.         bra.s        DNull
  272.  
  273.         SYMBOL        DStar
  274. DStar        move.b        #'*',(A6)+  ; output a star (times sign)
  275.         bra.s        DNull
  276.  
  277.         SYMBOL        DPlus
  278. DPlus        move.b        #'+',(A6)+
  279.         bra.s        DNull
  280.  
  281.         SYMBOL        DMinus
  282. DMinus        move.b        #'-',(A6)+
  283.         bra.s        DNull
  284.  
  285.         SYMBOL        DClose
  286. DClose        move.b        #')',(A6)+
  287.         bra.s        DNull
  288.  
  289.         SYMBOL        DImmediate
  290. DImmediate    move.b        #'#',(A6)+
  291.         bra.s        DNull
  292.  
  293.         SYMBOL        DDollar
  294. DDollar     move.b        #'$',(A6)+
  295.         bra.s        DNull
  296.  
  297.         SYMBOL        DSlash
  298. DSlash        move.b        #'/',(A6)+
  299.         bra        DNull
  300.  
  301.         SYMBOL        DColon
  302. DColon:     move.b        #':',(A6)+  ; output a colon
  303.         bra        DNull
  304.  
  305.         SYMBOL        DOpenCurly
  306. DOpenCurly:    move.b        #'{',(A6)+  ; output a open curly bracket
  307.         bra        DNull
  308.  
  309.         SYMBOL        DCloseCurly
  310. DCloseCurly:    move.b        #'}',(A6)+  ; output a close curly bracket
  311.         bra        DNull
  312.  
  313.         SYMBOL        DOpenBracket
  314. DOpenBracket:    move.b        #'[',(A6)+  ; output a open bracket
  315.         bra        DNull
  316.  
  317.         SYMBOL        DCloseBracket
  318. DCloseBracket:    move.b        #']',(A6)+  ; output a close bracket
  319.         bra        DNull
  320.  
  321. ;
  322. ; DByte
  323. ;
  324. ; Synopsis:
  325. ;    Formats the byte in D0.b as an ascii hex number, preceded by a $.
  326. ;
  327.         SYMBOL        DByte
  328. DByte        bsr        DDollar
  329.         SYMBOL        DByte1
  330. DByte1        move.w        D0,-(sp)
  331.         asr.w        #4,D0
  332.         bsr        DHex
  333.         move.w        (sp)+,D0
  334.         bra        DHex
  335.  
  336. ;
  337. ; DWord
  338. ;
  339. ; Synopsis:
  340. ;    Formats the word in D0.w as an ascii hex number, preceded by a $.
  341. ;
  342.         SYMBOL        DWord
  343. DWord        bsr        DDollar
  344.         SYMBOL        DWord1
  345. DWord1        move.w        D0,-(sp)
  346.         asr.w        #8,D0
  347.         bsr.s        DByte1        ; high byte
  348.         move.w        (sp)+,D0
  349.         bra.s        DByte1
  350.  
  351. ;
  352. ; DOffset
  353. ;
  354. ; Synopsis:
  355. ;    Formats the word in D0.w as an ascii hex number, preceded by a $.
  356. ;    Format as an offset;  negative numbers preceeded by a negative sign
  357.         SYMBOL        DOffset
  358. DOffset        tst.w        D0
  359.         bpl.s        1$
  360.         bsr        DMinus
  361.         neg.w        D0
  362. 1$:        bsr        DDollar
  363.         move.w        D0,-(sp)
  364.         asr.w        #8,D0
  365.         bsr.s        DByte1        ; high byte
  366.         move.w        (sp)+,D0
  367.         bra.s        DByte1
  368.  
  369. ;
  370. ; DLong
  371. ;
  372. ; Synopsis:
  373. ;    Formats the LONG in D0.L as an ascii hex number, preceded by a $.
  374. ;
  375.         SYMBOL        DLong    ;
  376. DLong        movem.l     d1-d7/a0-a6,-(sp)
  377.         move.l        d0,-(sp)        ; save d0...
  378.         move.l        d0,-(sp)        ; push for 'C' call
  379.         jsr        _LookupValue
  380.         addq        #4,sp
  381.         tst.l        d0
  382.         beq.s        10$            ; no symbol
  383.         tst.l        (sp)+            ; drop old D0
  384.         movem.l     (sp)+,d1-d7/a0-a6
  385.         move.l        d0,A1
  386.         bra        DString         ; display symbolic
  387.         ; not symbolic, print hex number...
  388. 10$        move.l        (sp)+,d0
  389.         movem.l     (sp)+,d1-d7/a0-a6
  390.  
  391.         move.l        D0,-(sp)
  392.         bsr        DDollar
  393.         swap        D0        ; do high word first
  394.         bsr.s        DWord1
  395. 20$        move.l        (sp)+,D0
  396.         bra.s        DWord1
  397.  
  398. ;
  399. ; EffectiveAddress
  400. ;
  401. ; Synopsis:
  402. ;    This routine takes an Effective Address and formats the
  403. ;    assembler language notation and puts it in outbuf.  This routine
  404. ;    determines the size of the instruction (byte, word, long) from
  405. ;    bits 2 & 3 of the D2 register, the mode from bits 0, 1, & 2 of the
  406. ;    D3 register, and the register number from bits 0, 1, & 2 of the D4
  407. ;    register.  If an Illegal Mode/Register combination occurs, this
  408. ;    routine pops the return address and jumps to invalid_instruction,
  409. ;    and for that reason this routine must be CALLed and never jumped to.
  410. ;
  411.  
  412.         SYMBOL        ModeTable            ;
  413. ModeTable                            ; Mode...
  414.         dc.l        DataRegisterDirect        ; 000
  415.         dc.l        AddressRegisterDirect        ; 001
  416.         dc.l        Indirect            ; 010
  417.         dc.l        PostIncrement            ; 011
  418.         dc.l        PreDecrement            ; 100
  419.         dc.l        IndirectDisplacement        ; 101
  420.         dc.l        IndirectIndex            ; 110
  421.         dc.l        SpecialMode            ; 111
  422.  
  423.         SYMBOL        SpecialModeTable        ;
  424. SpecialModeTable                        ; Register...
  425.         dc.l        AbsoluteShort            ; 000
  426.         dc.l        AbsoluteLong            ; 001
  427.         dc.l        ProgramCounterDisplacement    ; 010
  428.         dc.l        ProgramCounterIndex        ; 011
  429.         dc.l        ImmediateData            ; 100
  430.         dc.l        SpecialIllegal            ; 101
  431.         dc.l        SpecialIllegal            ; 110
  432.         dc.l        SpecialIllegal            ; 111
  433.  
  434.         SYMBOL        DestinationEA
  435. DestinationEA    move.w        D1,D3
  436.         asr.w        #6,D3
  437.         and.w        #7,D3
  438.  
  439.         move.w        D1,D4
  440.         rol        #7,D4
  441.         and.w        #7,D4
  442.         rts
  443.  
  444.         SYMBOL        EA
  445. EA        move.w        D1,D3
  446.         asr.w        #3,D3
  447.         and.w        #7,D3        ; D3 = MODE
  448.  
  449.         move.w        D1,D4
  450.         and.w        #7,D4        ; D4 = Register
  451.         rts
  452.  
  453.         SYMBOL        EffectiveAddress
  454. EffectiveAddress
  455.         move.w        D3,D0    ; Mode
  456.         lea        ModeTable,A1        ; jump table address
  457.         bra        JumpTable
  458.  
  459.         SYMBOL        DataRegisterDirect
  460. DataRegisterDirect
  461.         bsr        DD
  462.         move.b        D4,D0
  463.         bra        DHex
  464.  
  465.         SYMBOL        AddressRegisterDirect
  466. AddressRegisterDirect
  467.         bsr        DA
  468.         move.b        D4,D0
  469.         bra        DHex
  470.  
  471.         SYMBOL        Indirect
  472. Indirect    bsr        DOpen
  473.         bsr.s        AddressRegisterDirect
  474.         bra        DClose
  475.  
  476.         SYMBOL        PostIncrement
  477. PostIncrement    bsr        Indirect
  478.         bra        DPlus
  479.  
  480.         SYMBOL        PreDecrement
  481. PreDecrement    bsr        DMinus
  482.         bra.s        Indirect
  483.  
  484.         SYMBOL        IndirectDisplacement
  485.         XREF        _programA4
  486. IndirectDisplacement
  487.         moveq        #0,d0
  488.         bsr        FetchWord        ; fetch postword
  489.         cmp.b        #4,d4
  490.         bne.s        .notA4
  491.         move.w        d0,.temp
  492.         ext.l        d0
  493.         add.l        _programA4,d0
  494.         movem.l     d1-d7/a0-a6,-(sp)
  495.         move.l        d0,-(sp)
  496.         bsr        _LookupValue
  497.         addq.l        #4,sp
  498.         movem.l     (sp)+,d1-d7/a0-a6
  499.         tst.l        d0
  500.         beq.s        .notA4x
  501.         move.l        d0,a1
  502.         bsr        DString
  503.         bra.s        Indirect
  504. .notA4x     move.w        .temp,d0
  505. .notA4        bsr        DOffset            ; display it (changed from DWord to get neg sign)
  506.         bra.s        Indirect
  507. .temp        dc.w        0
  508.  
  509.         SYMBOL        IndirectIndex
  510. IndirectIndex:
  511.         bsr        FetchWord        ; fetch postword
  512.         move.w        D0,D5            ; preserve it
  513.         btst        #8,D5            ; check for enhanced indirect modes
  514.         bne.s        EnhancedIndirect
  515.         bsr        DOpen            ; copy a open paren to start
  516.         ext.w        D0            ; extend
  517.         beq.s        10$            ; skip if zero
  518.         bsr        DOffset            ; otherwise show it (was DWord)
  519.         bsr        DComma            ; copy a comma
  520. 10$:
  521.         bsr        AddressRegisterDirect
  522.         bclr        #6,D5        ; clear the index suppress bit
  523.         bsr        CommaIndexRegister    ; copy a comma then the index register
  524.         bra        DClose
  525.  
  526.  
  527.  
  528.         SYMBOL        EnhancedIndirect
  529. EnhancedIndirect:
  530.         move        D5,D0            ; get the outer displacment size
  531.         and        #3,D0
  532.         beq.s        RegIndirectIndex    ; register indirect index
  533.         lea        parenbracket_string(PC),A1
  534.         bsr        DString         ; copy a ([
  535.         bsr        BaseDisplacement    ; copy the base displacement
  536.  
  537.         btst        #7,D5            ; check if base is suppressed
  538.         beq.s        10$
  539.         bsr        DZ            ; base is suppressed so copy a Z
  540. 10$:        btst        #3,D3            ; check if PC or address
  541.         bne.s        15$            ; working on a PC relative instruction
  542.         bsr        AddressRegisterDirect    ; copy the address register
  543.         bra.s        18$
  544. 15$:        lea        pc_string(PC),A1    ; copy PC register string
  545.         bsr        DString
  546.  
  547. 18$:        btst        #2,D5            ; check if pre or post indexed
  548.         bne.s        20$            ; pre-indexed
  549.         bsr        DCloseBracket        ; copy a close bracket
  550.  
  551. 20$:        bsr        CommaIndexRegister    ; copy a comma then the index register
  552.         btst        #2,D5            ; check if pre or post indexed
  553.         beq.s        30$            ; post-indexed
  554.         bsr        DCloseBracket        ; copy a close bracket
  555.  
  556. 30$:        move        D5,D0
  557.         and        #3,D0            ; get the outer displacement size
  558.         bne.s        40$            ; valid displacement
  559.         addq.l        #4,SP            ; pop subroutine call
  560.         bra        invalid_instruction    ; invalid size used
  561.  
  562. 40$:        subq        #1,D0            ; shift it down one bit
  563.         beq.s        60$            ; no displacement field
  564.         bsr        DComma            ; copy a comma
  565.         subq        #1,D0            ; shift it down one more bit
  566.         bne.s        50$            ; LONGWORD base displacement
  567.         bsr        FetchWord        ; get the next WORD
  568.         bsr        DWord            ; copy the WORD
  569.         bra.s        60$
  570. 50$:        bsr        FetchLong        ; get the next LONGWORD
  571.         bsr        DLong            ; copy the LONGWORD
  572.  
  573. 60$:        bra        DClose            ; copy a close paren
  574.  
  575.  
  576.         SYMBOL        RegIndirectIndex
  577. RegIndirectIndex:
  578.         bsr        DOpen            ; copy a open paren
  579.         bsr        BaseDisplacement    ; copy the base displacement
  580.  
  581.         btst        #7,D5        ; check if base is suppressed
  582.         beq.s        10$
  583.         bsr        DZ            ; base is suppressed so copy a Z
  584. 10$:        btst        #3,D3        ; check if PC or address
  585.         bne.s        20$            ; working on a PC relative instruction
  586.         bsr        AddressRegisterDirect    ; copy the address register
  587.         bra.s        30$
  588. 20$:        lea        pc_string(PC),A1    ; copy PC register string
  589.         bsr        DString
  590.  
  591. 30$:        bsr        CommaIndexRegister    ; copy a comma then the index register
  592.         bra        DClose            ; copy a close paren
  593.  
  594.  
  595.         SYMBOL        SpecialMode
  596. SpecialMode    move.w        D4,D0    ; Register
  597.         lea        SpecialModeTable,A1    ; jump table address
  598.         bra        JumpTable
  599.  
  600.  
  601.  
  602.  
  603.         SYMBOL        AbsoluteShort
  604. AbsoluteShort    moveq        #0,D0
  605.         bsr        FetchWord        ; fetch PostWord
  606.         move.l        d0,-(sp)        ; save d0...
  607.         movem.l     d1-d7/a0-a6,-(sp)
  608.  
  609.         ext.l        d0            ; sign extend for lookup
  610.         move.l        d0,-(sp)        ; push for 'C' call
  611.         jsr        _LookupValue
  612.         addq        #4,sp
  613.         tst.l        d0
  614.         beq.s        10$            ; no symbol
  615.  
  616.         movem.l     (sp)+,d1-d7/a0-a6
  617.         tst.l        (sp)+            ; drop old D0
  618.  
  619.         bsr        DOpen
  620.         move.l        d0,A1
  621.         bsr        DString         ; display symbolic
  622.         bsr        DClose
  623.         lea        w_string,A1
  624.         bra        DString
  625.  
  626.         ; not symbolic, print hex number...
  627. 10$        movem.l     (sp)+,d1-d7/a0-a6
  628.         move.l        (sp)+,d0
  629.  
  630.         bsr        DWord            ; and show address
  631.         lea        w_string,A1
  632.         bra        DString
  633.  
  634.         SYMBOL        AbsoluteLong
  635. AbsoluteLong    bsr        FetchLong        ; fetch Post Longword
  636.         bra        DLong
  637. ;        lea        l_string,A1
  638. ;        bra        DString
  639.  
  640.         SYMBOL        ProgramCounterDisplacement
  641. ProgramCounterDisplacement
  642.         bsr        FetchWord        ; Fetch PostWord
  643.         ext.l        D0        ; sign extend it
  644.         add.l        D7,D0 ; add Program Counter
  645.         addq.l        #2,D0        ; so LookupValue works
  646.         bsr        DLong
  647.         lea        pcr_string,A1
  648.         bra        DString
  649.  
  650.         SYMBOL        ProgramCounterIndex
  651. ProgramCounterIndex
  652.         bsr        FetchWord        ; Fetch PostWord
  653.         move.w        D0,D5    ; preserve it
  654.         btst        #8,D5        ; check for enhanced indirect modes
  655.         bne        EnhancedIndirect
  656.         ext.w        D0        ; sign extend offset
  657.         ext.l        D0        ; into a long offset
  658.         add.l        D7,D0 ; add in PC
  659.         bsr        DLong
  660.  
  661.         bclr        #6,D5        ; clear the index suppress bit
  662.         bsr        OpenIndexRegister    ; copy a paren then the index register
  663.         bra        DClose            ; )
  664.  
  665.  
  666.         SYMBOL        ImmediateData
  667. ImmediateData    bsr        DImmediate
  668.         cmp.b        #8,D2        ; long?
  669.         bne.s        10$
  670.         bsr        FetchLong
  671.         bra        DLong
  672. 10$        bsr        FetchWord
  673.         cmp.b        #4,D2        ; word?
  674.         bne        DByte
  675.         bra        DWord
  676.  
  677.         SYMBOL        SpecialIllegal
  678. SpecialIllegal    lea        4(sp),sp
  679.         bra        invalid_instruction
  680.  
  681. ;
  682. ; IndexRegister
  683. ; CommaIndexRegister
  684. ; OpenIndexRegister
  685. ;
  686. ; Synopsis:
  687. ;    Output a index register stored in bits 12-14 of D5 in the form
  688. ;    Xn.SIZE*SCALE, if the index has not be suppressed.
  689. ;
  690.         SYMBOL        OpenIndexRegister
  691. OpenIndexRegister:
  692.         move.b        #'(',D0         ; copy a open paren
  693.         bra.s        IndexRegister
  694.         SYMBOL        CommaIndexRegister
  695. CommaIndexRegister:
  696.         move.b        #',',D0         ; copy a comma
  697.         SYMBOL        IndexRegister
  698. IndexRegister:
  699.         btst        #6,D5        ; check if index is suppressed
  700.         bne.s        60$
  701.  
  702.         bsr        DChar            ; copy the starting character
  703.         move        D5,D0    ; get postword again
  704.         btst        #15,D0        ; Data or address reg
  705.         beq.s        20$
  706.         bsr        DA
  707.         bra.s        30$
  708. 20$:        bsr        DD
  709.  
  710. 30$:        move.w        D5,D0    ; get postword again
  711.         rol        #4,D0        ; get top 4 bits
  712.         and        #7,D0        ; isolate register #
  713.         bsr        DHex            ; show it
  714.  
  715.         lea        l_string,A1
  716.         move.w        D5,D0    ; get postword final time
  717.         btst        #11,D0
  718.         bne        40$
  719.         lea        w_string,A1
  720. 40$:        bsr        DString
  721.         bsr        scale910        ; get the scaling
  722.         beq.s        60$            ; no scaling used (or 68000)
  723.         bsr        DStar            ; copy a star
  724.         move.b        ScaleTable(PC,D0),D0
  725.         bsr        DHex            ; copy the ASCII scale value
  726. 60$:        rts
  727.  
  728.         SYMBOL        ScaleTable
  729. ScaleTable:    DC.B        0,2,4,8         ; register scaling values
  730.  
  731. ;
  732. ; BaseDisplacement
  733. ;
  734. ; Synopsis:
  735. ;    Output a base displacement for the enhanced addressing modes with
  736. ;    the size in bits 4-5 of D5. If a invalid size is found, the
  737. ;    call this routine and the EA routine are poped from the stack and
  738. ;    control is turned over to invalid_instruction.
  739. ;
  740.         SYMBOL        BaseDisplacement
  741. BaseDisplacement:
  742.         move        D5,D0
  743.         lsr        #5,D0        ; get the base displacment size
  744.         and        #3,D0
  745.         bne.s        5$            ; valid displacement
  746.         addq.l        #8,SP            ; remove 2 subroutine calls
  747.         bra        invalid_instruction    ; invalid size used
  748.  
  749. 5$:        subq        #1,D0        ; shift it down one bit
  750.         beq.s        30$            ; no displacement field
  751.         subq        #1,D0        ; shift it down one more bit
  752.         bne.s        10$            ; LONGWORD base displacement
  753.         bsr        FetchWord        ; get the next WORD
  754.         bsr        DWord            ; copy the WORD
  755.         bra.s        20$
  756. 10$:        bsr        FetchLong        ; get the next LONGWORD
  757.         bsr        DLong            ; copy the LONGWORD
  758. 20$:        bsr        DComma            ; copy a comma
  759. 30$:        rts
  760.  
  761.  
  762.  
  763. ***** Utility routines for instruction decoding routines
  764.  
  765. ;
  766. ; Size67
  767. ; Size910
  768. ;
  769. ; Synopsis:
  770. ;    Extracts the size of the instruction (byte, word, long) from
  771. ;    bits 6 & 7 of the instruction word in D1.  If bits 6 and 7 are
  772. ;    both set, then this routine pops the return address and jumps
  773. ;    to invalid_instruction.  If a legal value, the ".b", ".w", or
  774. ;    ".l" string is appended to outbuf, as well as a TAB.  This
  775. ;    Routine sets D2 to the appropriate size value for effective
  776. ;    address routines to look at.
  777. ;
  778. ; NOTE:
  779. ;    Because this routine pops the return address, you must ALWAYS
  780. ;    call it and not jump to it!!!
  781. ;
  782.  
  783.         SYMBOL        size67_table
  784. size67_table    dc.l        b_string,w_string,l_string,0
  785.  
  786.         SYMBOL        Size910
  787. Size910:    move        D1,D2        ; get the size bits
  788.         rol        #7,D2        ; rotate upper 7 bits
  789.         and        #3,D2        ; keep only bits 9&10
  790.         subq        #1,D2        ; adjust to bits 6&7 size range
  791.         bra.s        DSize        ; copy the size extension
  792.  
  793.  
  794.         SYMBOL        Size67
  795. Size67        move.w        D1,D2
  796.         asr.w        #4,D2
  797.  
  798.         SYMBOL        DSize
  799. DSize        lea        size67_table,A1
  800.         and.w        #$000c,D2        ; bits 6&7 * 4 (bytes/long)
  801.         move.l        0(A1,D2.w),D0 ; fetch string address
  802.         bne.s        10$            ; it was legal size
  803.         lea        4(sp),sp        ; drop return address
  804.         bra        invalid_instruction
  805. 10$        move.l        D0,A1        ; address of string (".b", etc.)
  806.         bsr        DString
  807.         bra        DTab
  808.  
  809.  
  810. ;
  811. ; scale910
  812. ;
  813. ; Synopsis:
  814. ;    This subroutine extracts a scaling value for the register from bits 9-10
  815. ;    of D5 and returns it in D0.
  816. ;
  817.         SYMBOL        scale910
  818. scale910:    move        D5,D0    ; get the extension WORD
  819.         rol        #7,D0        ; move the bits down
  820.         and        #3,D0        ; keep only the scale
  821.         rts
  822.  
  823. ;
  824. ; dreg911
  825. ;
  826. ; Synopsis:
  827. ;    This subroutine extracts a register number from bits 9-11 of
  828. ;    D1 and formats the register as D0-D7.
  829. ;
  830. ; reg911
  831. ;
  832. ; Synopsis:
  833. ;    This routine extracts register number as in dreg911, but only formats
  834. ;    the register number as 0-7.
  835. ;
  836.  
  837.         SYMBOL        dreg02
  838. dreg02        bsr        DD
  839.         bra.s        reg02
  840.  
  841.         SYMBOL        areg02
  842. areg02        bsr        DA
  843.  
  844.         SYMBOL        reg02
  845. reg02        move.w        D1,D0
  846.         and.w        #7,D0
  847.         bra        DHex
  848.  
  849.  
  850.         SYMBOL        dreg911
  851. dreg911     bsr        DD
  852.         bra.s        reg911
  853.  
  854.         SYMBOL        areg911
  855. areg911     bsr        DA
  856.  
  857.         SYMBOL        reg911
  858. reg911        move.w        D1,D0
  859.         rol        #7,D0
  860.         and.w        #7,D0
  861.         bra        DHex
  862.  
  863.  
  864. ;
  865. ; Scratch1Dreg1214
  866. ; dreg1214
  867. ; areg1214
  868. ; reg1214
  869. ;
  870. ; Synopsis:
  871. ;    This subroutine extracts a register number from bits 12-14 of
  872. ;    D0 and formats the register as 0-7.
  873. ;
  874.  
  875.         SYMBOL        Scratch1Dreg1214
  876. Scratch1Dreg1214:
  877.         move        D5,D0    ; get the extension WORD
  878.  
  879.         SYMBOL        dreg1214
  880. dreg1214:    bsr        DD            ; copy a D first
  881.         bra.s        reg1214
  882.  
  883.         SYMBOL        areg1214
  884. areg1214:    bsr        DA            ; copy a A first
  885.  
  886.         SYMBOL        reg1214
  887. reg1214:    rol        #4,D0        ; get the register number
  888.         and        #7,D0        ; keep only the number
  889.         bra        DHex            ; copy the ASCII character
  890.  
  891.         SYMBOL        Dreg
  892. Dreg:        bsr        DD            ; copy a D first
  893.         and        #7,D0        ; keep only the number
  894.         bra        DHex            ; copy the ASCII character
  895.  
  896.  
  897.  
  898.         SYMBOL        invalid_instruction
  899. invalid_instruction
  900.         move.l        16(A5),A6    ; destroy previous string...
  901. ;;;        bsr        DTab
  902.         lea        dcw_string,A1
  903.         bsr        DString
  904.         bsr        DTab
  905.         move.w        D1,D0
  906.         bsr        DWord
  907.         bsr        DTab
  908.         lea        invalid_string,A1
  909.         bsr        DString
  910.         moveq        #2,D2
  911.         rts
  912.  
  913.         SYMBOL        immediate_instruction
  914. immediate_instruction
  915.         bsr        DString
  916.         cmp.b        #$3c,D1
  917.         beq        immediate_ccr_instruction
  918.         cmp.b        #$7c,D1
  919.         beq        immediate_sr_instruction
  920.         bsr        Size67        ; extract the size info
  921.         SYMBOL        immediate_operand
  922. immediate_operand:
  923.         bsr        ImmediateData
  924.         bsr        DComma
  925.         bsr        EA        ; Effective Address D1 bits 0-5
  926.         bsr        EffectiveAddress
  927.         rts
  928.  
  929.         SYMBOL        immediate_ccr_instruction
  930. immediate_ccr_instruction
  931.         bsr    DTab
  932.         moveq        #0,D2        ; size = BYTE
  933.         bsr        ImmediateData
  934.         bsr        DComma
  935.         lea        ccr_string,A1
  936.         bra        DString
  937.  
  938.         SYMBOL        immediate_sr_instruction
  939. immediate_sr_instruction
  940.         bsr    DTab
  941.         moveq        #4,D2        ; size = WORD
  942.         bsr        ImmediateData
  943.         bsr        DComma
  944.         lea        sr_string,A1
  945.         bra        DString
  946.  
  947.  
  948.  
  949. ***** Bit Manipulation/MOVEP/Immediate Instructions
  950.  
  951.         SYMBOL        ori_instruction
  952. ori_instruction
  953.         lea        ori_string,A1
  954.         bra        immediate_instruction
  955.  
  956.         SYMBOL        andi_instruction
  957. andi_instruction
  958.         lea        andi_string,A1
  959.         bra        immediate_instruction
  960.  
  961.         SYMBOL        subi_instruction
  962. subi_instruction
  963.         lea        subi_string,A1
  964.         bra        immediate_instruction
  965.  
  966.         SYMBOL        addi_instruction
  967. addi_instruction
  968.         bsr        test67            ; check for CALLM
  969.         beq.s        callm_instruction
  970.         lea        addi_string,A1
  971.         bra        immediate_instruction
  972.  
  973.         SYMBOL        callm_instruction
  974. callm_instruction:
  975.         lea        callm_string(PC),A1    ; copy the instruction
  976.         bsr        DString
  977.         bsr        DTab            ; move to the next column
  978.         moveq        #0,D2        ; size = BYTE
  979.         bra        immediate_operand    ; copy the immediate operand
  980.  
  981.         SYMBOL        moves_instruction
  982. moves_instruction:
  983.         lea        moves_string(PC),A1    ; copy the instruction
  984.         bsr        DString
  985.         bsr        Size67            ; copy the size extension
  986.  
  987.         bsr        EA            ; get the <EA>
  988.         bsr        FetchWord        ; get the extension WORD
  989.         move        D0,D5
  990.         btst        #11,D0        ; check with direction
  991.         beq.s        10$            ; MOVES <EA>,Rn
  992.         bsr        dareg_operand        ; copy the register
  993.         bsr        DComma            ; copy a comma
  994.         bsr        EffectiveAddress    ; copy the effective address
  995.         rts
  996.  
  997. 10$:        bsr        EffectiveAddress    ; copy the effective address
  998.         bsr        DComma            ; copy a comma
  999.         move        D5,D0
  1000.         bra        dareg_operand        ; copy the register
  1001.  
  1002.         SYMBOL        eori_instruction
  1003. eori_instruction
  1004.         bsr        test67            ; check for CAS[2]
  1005.         beq.s        cas_instruction
  1006.         lea        eori_string,A1
  1007.         bra        immediate_instruction
  1008.  
  1009.         SYMBOL        cmpi_instruction
  1010. cmpi_instruction
  1011.         bsr        test67            ; check for CAS[2] instruction
  1012.         beq.s        cas_instruction
  1013.         lea        cmpi_string,A1
  1014.         bra        immediate_instruction
  1015.  
  1016.         SYMBOL        rtm_instruction
  1017. rtm_instruction:
  1018.         btst        #11,D1        ; check for MOVES instruction
  1019.         bne.s        moves_instruction
  1020.         lea        rtm_string(PC),A1      ; copy the instruction
  1021.         bsr        DString
  1022.         bsr        DTab            ; move to the next column
  1023.         btst        #3,D1        ; check if Data or Address
  1024.         beq        dreg02            ; copy Data register
  1025.         bra        areg02            ; copy Address register
  1026.  
  1027.  
  1028.         SYMBOL        cas_instruction
  1029. cas_instruction:
  1030.         bsr        test67            ; check for RTM/MOVES
  1031.         bne.s        rtm_instruction
  1032.  
  1033.         move        D1,D0    ; get the <EA>
  1034.         and        #$3f,D0
  1035.         cmp        #$3c,D0     ; check for 111100 mode
  1036.         beq.s        cas2_instruction
  1037.         lea        cas_string(PC),A1    ; copy the instruction
  1038.         bsr        DString
  1039.         bsr        Size910         ; copy the size extension
  1040.         bsr        FetchWord        ; get the extension WORD
  1041.         move        D0,D5
  1042.         bsr        Dreg            ; copy register Dc
  1043.  
  1044.         bsr        DComma            ; copy a comma
  1045.         move        D5,D0
  1046.         lsr        #6,D0        ; copy register Du
  1047.         bsr        Dreg
  1048.         bsr        DComma            ; copy a comma
  1049.  
  1050.         bsr        EA            ; get the <EA>
  1051.         bsr        EffectiveAddress    ; copy the effective address
  1052.         rts
  1053.  
  1054.         SYMBOL        cas2_instruction
  1055. cas2_instruction:
  1056.         btst        #11,D1    ; check for CHK2 instruction
  1057.         beq        chk2_instruction
  1058.  
  1059.         lea        cas2_string(PC),A1    ; copy the instruction
  1060.         bsr        DString
  1061.         bsr        Size910         ; copy the size extension
  1062.         bsr        FetchLong        ; get next 2 extension WORDs
  1063.         swap        D0        ; swap the extension WORDs
  1064.         move.l        D0,D5
  1065.  
  1066.         bsr        Dreg            ; copy register Dc1
  1067.         bsr        DColon            ; copy a colon
  1068.         swap        D0        ; get second extension WORD
  1069.         bsr        Dreg            ; copy register Dc2
  1070.         bsr        DComma            ; copy a comma
  1071.  
  1072.         move.l        D5,D0
  1073.         lsr        #6,D0
  1074.         bsr        Dreg            ; copy register Du1
  1075.         bsr        DColon            ; copy a colon
  1076.         swap        D0        ; get second extension WORD
  1077.         lsr        #6,D0
  1078.         bsr        Dreg            ; copy register Du2
  1079.         bsr        DComma            ; copy a comma
  1080.  
  1081.         move.l        D5,D0
  1082.         bsr.s        DDAreg1214        ; copy a register in form (Rn)
  1083.         swap        D0        ; get second extension WORD
  1084.  
  1085.         SYMBOL        DDAreg1214
  1086. DDAreg1214:    bsr        DOpen            ; copy a open paren
  1087.         btst        #15,D0        ; check if Data or Address
  1088.         beq.s        10$
  1089.         bsr        areg1214        ; copy Address register
  1090.         bra.s        20$
  1091. 10$:        bsr        dreg1214        ; copy Data register
  1092. 20$:        bra        DClose            ; copy a close paren
  1093.  
  1094.  
  1095.         SYMBOL        chk2_instruction
  1096. chk2_instruction:
  1097.         lea        chk2_string(PC),A1     ; copy the instruction
  1098.         bsr        FetchWord        ; get the extension WORD
  1099.         move        D0,D5
  1100.         btst        #11,D0        ; check for CMP2 instruction
  1101.         bne.s        eareg_instruction
  1102.  
  1103. ;
  1104. ; CMP2 instruction
  1105. ;
  1106.         lea        cmp2_string(PC),A1     ; copy the instruction
  1107.  
  1108.         SYMBOL        eareg_instruction
  1109. eareg_instruction:
  1110.         bsr        DString
  1111.         bsr        Size910         ; copy the size extension
  1112.         bsr        DTab            ; move to the next column
  1113.         bsr        EA            ; get the <EA>
  1114.         bsr        EffectiveAddress    ; copy the effective address
  1115.         bsr        DComma            ; copy a comma
  1116.         SYMBOL        dareg_operand
  1117. dareg_operand:
  1118.         move        D5,D0    ; get the extension WORD
  1119.         btst        #15,D0        ; check if Data or Address
  1120.         beq        dreg1214        ; copy Data register
  1121.         bra        areg1214        ; copy Address register
  1122.  
  1123.  
  1124.         SYMBOL        movep_instruction
  1125. movep_instruction
  1126.         move.w        D1,D0    ; Instruction Word
  1127.         and.w        #$38,D0
  1128.         cmp.w        #$38,D0
  1129.         beq        dynamic_bit
  1130.  
  1131.         lea        movep_string,A1
  1132.         bsr        DString
  1133.         lea        l_string,A1
  1134.         btst        #6,D1        ; w/l bit
  1135.         bne.s        10$
  1136.         lea        w_string,A1
  1137. 10$        bsr        DString
  1138.         bsr        DTab
  1139.         btst        #7,D1        ; direction bit
  1140.         bne.s        20$
  1141.         ; memory to register...
  1142.         move.w        D1,D4
  1143.         and.w        #7,D4        ; register
  1144.         bsr        IndirectIndex
  1145.  
  1146.         bsr        DComma
  1147.  
  1148.         move.w        D1,D4
  1149.         rol        #7,D4
  1150.         and.w        #7,D4
  1151.         bra        DataRegisterDirect
  1152.  
  1153.         ; register to memory
  1154. 20$        move.w        D1,D4
  1155.         rol        #7,D4
  1156.         and.w        #7,D4
  1157.         bsr        DataRegisterDirect
  1158.         bsr        DComma
  1159.         move.w        D1,D4
  1160.         and.w        #7,D4
  1161.         bra        IndirectDisplacement
  1162.  
  1163.  
  1164.         SYMBOL        bit_type
  1165. bit_type
  1166.         bsr        DB
  1167.         move.w        D1,D0
  1168.         asr.w        #4,D0
  1169.         and.w        #$000c,D0
  1170.         lea        bit_type_table,A1
  1171.         move.l        0(A1,D0.w),A1
  1172.         bsr        DString
  1173.         bra        DTab
  1174.  
  1175.  
  1176.         SYMBOL        dynamic_bit
  1177. dynamic_bit
  1178.         bsr        bit_type
  1179.         move.w        D1,D0
  1180.         asr.w        #8,D4
  1181.         asr.w        #1,D4
  1182.         and.w        #7,D4
  1183.         bsr        DataRegisterDirect
  1184.         bsr        DComma
  1185.         bsr        EA        ; MUST BE BSR THEN RTS:
  1186.         bsr        EffectiveAddress
  1187.         rts                ; DON'T DELETE ME
  1188.  
  1189.  
  1190.         SYMBOL        static_bit
  1191. static_bit
  1192.         bsr        bit_type
  1193.         move.w        D1,D0    ; instruction
  1194.         and.w        #$38,D0     ; isolate mode bits
  1195.         beq.s        10$            ; is not data register
  1196.  
  1197.         bsr        FetchWord
  1198. ;        cmp.b        #7,D0        ; check count
  1199. ;        bgt        invalid_instruction
  1200.         bra.s        20$
  1201. 10$        bsr        FetchWord
  1202. 20$        bsr        DImmediate
  1203.         bsr        DByte
  1204.         bsr        DComma
  1205.         bsr        EA
  1206.         bsr        EffectiveAddress
  1207.         rts
  1208.  
  1209.  
  1210.         SYMBOL        bit_type_table
  1211. bit_type_table
  1212.         dc.l        tst_string,chg_string,clr_string,set_string
  1213.  
  1214.         SYMBOL        OpTable0
  1215.         ;                    ; bits 8-11
  1216. OpTable0    dc.l        ori_instruction     ; 0000
  1217.         dc.l        movep_instruction    ; 0001
  1218.         dc.l        andi_instruction    ; 0002
  1219.         dc.l        movep_instruction    ; 0003
  1220.         dc.l        subi_instruction    ; 0004
  1221.         dc.l        movep_instruction    ; 0005
  1222.         dc.l        addi_instruction    ; 0006
  1223.         dc.l        movep_instruction    ; 0007
  1224.         dc.l        static_bit        ; 0008
  1225.         dc.l        movep_instruction    ; 0009
  1226.         dc.l        eori_instruction    ; 0010
  1227.         dc.l        movep_instruction    ; 0011
  1228.         dc.l        cmpi_instruction    ; 0012
  1229.         dc.l        movep_instruction    ; 0013
  1230.         dc.l        cas_instruction     ; 0014
  1231.         dc.l        movep_instruction    ; 0015
  1232.  
  1233.  
  1234.         SYMBOL        Group0
  1235. Group0        move.w        D1,D0    ; Instruction Word
  1236.         asr.w        #8,D0
  1237.         and.w        #$000f,D0    ; isolate bits 8-11
  1238.         lea        OpTable0,A1
  1239.         bra        JumpTable
  1240.  
  1241. **** MOVE (BYTE,WORD,LONG)
  1242.  
  1243.  
  1244.         SYMBOL        Group1
  1245. Group1
  1246.         moveq        #0,D2
  1247.         bra.s        move_instruction
  1248.  
  1249.         SYMBOL        Group2
  1250. Group2
  1251.         moveq        #8,D2
  1252.         bra.s        move_instruction
  1253.  
  1254.         SYMBOL        Group3
  1255. Group3
  1256.         moveq        #4,D2
  1257.  
  1258.  
  1259.         SYMBOL        move_instruction
  1260. move_instruction
  1261.         lea        move_string,A1
  1262.         bsr        DString
  1263.         bsr        DSize
  1264.         bsr        EA
  1265.         bsr        EffectiveAddress
  1266.         bsr        DComma
  1267.         bsr        DestinationEA
  1268.         bsr        EffectiveAddress
  1269.         rts
  1270.  
  1271.  
  1272.  
  1273. **** Miscelaneous
  1274.  
  1275.  
  1276.         SYMBOL        DMove
  1277. DMove
  1278.         lea        move_string,A1
  1279.         bra        DString
  1280.  
  1281.  
  1282.         SYMBOL        test67
  1283. test67
  1284.         move.w        D1,D0
  1285.         and.b        #$c0,D0
  1286.         cmp.b        #$c0,D0
  1287.         rts
  1288.  
  1289.  
  1290.         SYMBOL        SizeEADString
  1291. SizeEADString
  1292.         bsr        DString
  1293.  
  1294.         SYMBOL        SizeEA
  1295. SizeEA
  1296.         bsr        Size67
  1297.  
  1298.         SYMBOL        JustEA
  1299. JustEA
  1300.         bsr        EA
  1301.         bsr        EffectiveAddress
  1302.         rts
  1303.  
  1304.  
  1305.         SYMBOL        negx_instruction
  1306. negx_instruction
  1307.         bsr        test67
  1308.         beq.s        from_sr_instruction
  1309.         lea        negx_string,A1
  1310.         bra.s        SizeEADString
  1311.  
  1312.         SYMBOL        from_sr_instruction
  1313. from_sr_instruction
  1314.         bsr        DMove
  1315.         bsr        DTab
  1316.         lea        sr_string,A1
  1317.         bsr        DString
  1318.         bsr        DComma
  1319.         moveq        #0,D2        ; size = byte
  1320.         bra.s        JustEA
  1321.  
  1322.         SYMBOL        clr_instruction
  1323. clr_instruction:
  1324.         bsr        test67            ; check for MOVE CCR,<EA>
  1325.         beq.s        from_ccr_instruction
  1326.         lea        clr_string,A1
  1327.         bra.s        SizeEADString
  1328.  
  1329.         SYMBOL        neg_instruction
  1330. neg_instruction
  1331.         bsr        test67
  1332.         beq.s        to_ccr_instruction
  1333.         lea        neg_string,A1
  1334.         bra.s        SizeEADString
  1335.  
  1336.         SYMBOL        from_ccr_instruction
  1337. from_ccr_instruction:
  1338.         bsr        DMove            ; copy MOVE instruction
  1339.         bsr        DTab            ; move the the next column
  1340.         lea        ccr_string(PC),A1      ; copy CCR string
  1341.         bsr        DString
  1342.         bsr        DComma            ; copy a comma
  1343.         moveq        #0,D2        ; size = BYTE
  1344.         bra.s        JustEA            ; copy the <EA>
  1345.  
  1346.         SYMBOL        to_ccr_instruction
  1347. to_ccr_instruction
  1348.         bsr        DMove
  1349.         bsr        DTab
  1350.         moveq        #4,D2        ; size = word
  1351.         bsr        EA
  1352.         bsr        EffectiveAddress
  1353.         bsr        DComma
  1354.         lea        ccr_string,A1
  1355.         bra        DString
  1356.  
  1357.         SYMBOL        not_instruction
  1358. not_instruction
  1359.         bsr        test67
  1360.         beq.s        to_sr_instruction
  1361.         lea        not_string,A1
  1362.         bra        SizeEADString
  1363.  
  1364.         SYMBOL        to_sr_instruction
  1365. to_sr_instruction
  1366.         bsr        DMove
  1367.         bsr        DTab
  1368.         moveq        #4,D2        ; size = byte
  1369.         bsr        EA
  1370.         bsr        EffectiveAddress
  1371.         bsr        DComma
  1372.         lea        sr_string,A1
  1373.         bra        DString
  1374.  
  1375.         SYMBOL        nbcd_instruction
  1376. nbcd_instruction
  1377.         move.w        D1,D0    ; instruction word
  1378.         and.w        #$f8,D0     ; strip off bits
  1379.         cmp.b        #$40,D0
  1380.         beq        swap_instruction
  1381.         cmp.b        #$80,D0
  1382.         beq        extw_instruction
  1383.         cmp.b        #$c0,D0
  1384.         beq        extl_instruction
  1385.  
  1386.         btst        #7,D1
  1387.         bne        movem_instruction
  1388.         btst        #6,D1
  1389.         bne.s        pea_instruction
  1390.  
  1391.         move        D1,D0    ; check for LONG LINK
  1392.         and.b        #$38,D0     ; keep MODE bits
  1393.         cmp.b        #8,D0        ; check for LINK
  1394.         beq.s        linkl_instruction
  1395.  
  1396.         lea        nbcd_string,A1
  1397.         bsr        DString
  1398.         bsr        DTab
  1399.         moveq        #0,D2        ; size = byte
  1400.         bra        JustEA
  1401.  
  1402.         SYMBOL        linkl_instruction
  1403. linkl_instruction:
  1404.         lea        link_string(PC),A1     ; copy the LINK instruction
  1405.         bsr        DString
  1406.         bsr        DTab            ; move to the next column
  1407.         bsr        DA            ; copy a A
  1408.         move        D1,D0
  1409.         and        #7,D0        ; get the register number
  1410.         bsr        DHex            ; copy the ASCII number
  1411.         bsr        DComma            ; copy a comma
  1412.         bsr        DImmediate        ; copy a immediate character
  1413.         bsr        FetchLong        ; get the LONGWORD offset
  1414.         bra        DLong            ; copy the LONGWORD
  1415.  
  1416.         SYMBOL        link_instruction
  1417. link_instruction
  1418.         lea        link_string,A1
  1419.         bsr        DString
  1420.         bsr        DTab
  1421.         bsr        DA
  1422.         move.w        D1,D0
  1423.         and.w        #7,D0
  1424.         bsr        DHex
  1425.         bsr        DComma
  1426.         bsr        DImmediate
  1427.         bsr        FetchWord
  1428.         bra        DWord
  1429.  
  1430.         SYMBOL        pea_instruction
  1431. pea_instruction
  1432.         lea        pea_string,A1
  1433.         bsr        DString
  1434.         bsr        DTab
  1435.         moveq        #8,D2        ; size = long
  1436.         bra        JustEA
  1437.  
  1438.         SYMBOL        swap_instruction
  1439. swap_instruction
  1440.         btst        #3,D1        ; check for BKPT instruction
  1441.         beq.s        bkpt_instruction
  1442.         lea        swap_string,A1
  1443.         bsr        DString
  1444.         bsr        DTab
  1445.         move.w        D1,D0    ; instruction word
  1446.         and.w        #7,D0        ; isolate register bits
  1447.         bsr        DD
  1448.         bra        DHex
  1449.  
  1450.         SYMBOL        bkpt_instruction
  1451. bkpt_instruction:
  1452.         lea        bkpt_string(PC),A1     ; copy the instruction name
  1453.         bsr        DString
  1454.         bsr        DTab            ; move the the next column
  1455.         move        D1,D0
  1456.         and        #7,D0        ; keep only the vector number
  1457.         bsr        DImmediate        ; copy immediate character
  1458.         bra        DByte            ; copy a ASCII BYTE
  1459.  
  1460.         SYMBOL        extw_instruction
  1461. extw_instruction
  1462.         lea        extw_string,A1
  1463.         bra.s        ext_instruction
  1464.  
  1465.         SYMBOL        extl_instruction
  1466. extl_instruction
  1467.         btst        #8,D1        ; check if its a EXTB.L
  1468.         bne.s        extbl_instruction
  1469.         lea        extl_string,A1
  1470.         bra.s        ext_instruction
  1471.  
  1472.         SYMBOL        extbl_instruction
  1473. extbl_instruction:
  1474.         lea        extbl_string(PC),A1    ; copy EXTB.L instruction
  1475.  
  1476.         SYMBOL        ext_instruction
  1477. ext_instruction
  1478.         bsr        DString
  1479.         bsr        DTab
  1480.         bsr        DD
  1481.         move.w        D1,D0
  1482.         and.w        #7,D0
  1483.         bra        DHex
  1484.  
  1485.         SYMBOL        tst_instruction
  1486. tst_instruction
  1487.         bsr        test67
  1488.         beq.s        tas_instruction
  1489.         lea        tst_string,A1
  1490.         bra        SizeEADString
  1491.  
  1492.         SYMBOL        tas_instruction
  1493. tas_instruction
  1494.         move.w        D1,D0    ; instruction word
  1495.         and.w        #$3f,D0
  1496.         cmp.w        #$3c,D0
  1497.         beq.s        illegal_instruction
  1498.         lea        tas_string,A1
  1499.         bsr        DString
  1500.         bsr        DTab
  1501.         moveq        #0,D2        ; size = 0
  1502.         bra        JustEA
  1503.  
  1504.         SYMBOL        illegal_instruction
  1505. illegal_instruction
  1506.         lea        illegal_string,A1
  1507.         bra        DString
  1508.  
  1509.         SYMBOL        divl_table
  1510. divl_table:    DC.L        divul_string,divull_string,divsl_string,divsll_string
  1511.  
  1512.         SYMBOL        mull_table
  1513. mull_table:    DC.L        mulul_string,mulull_string,mulsl_string,mulsll_string
  1514.  
  1515.         SYMBOL        divl_instructions
  1516. divl_instructions:
  1517.         bsr        FetchWord        ; get the extension WORD
  1518.         move        D0,D5
  1519.         lsr        #8,D0        ; get bits 10&11 * 4
  1520.         and        #$c,D0
  1521.         move.l        divl_table(PC,D0),A1
  1522.         bra.s        math_instruction
  1523.  
  1524.         SYMBOL        lmath_instructions
  1525. lmath_instructions:
  1526.         btst        #6,D1        ; check for LONG DIV instructions
  1527.         bne.s        divl_instructions
  1528. ;
  1529. ; LONG MULU/MULS instructions
  1530. ;
  1531.         bsr        FetchWord        ; get the extension WORD
  1532.         move        D0,D5
  1533.         lsr        #8,D0        ; get bits 10&11 * 4
  1534.         and        #$c,D0
  1535.         move.l        mull_table(PC,D0),A1
  1536.         SYMBOL        math_instruction
  1537. math_instruction:
  1538.         bsr        DString         ; copy the instruction
  1539.         bsr        DTab            ; move to the next column
  1540.  
  1541.         bsr        EA            ; get the <EA>
  1542.         bsr        EffectiveAddress    ; copy the effective address
  1543.         bsr        DComma            ; copy a comma
  1544.  
  1545.         move        D5,D0
  1546.         and        #7,D0        ; get Dr/Dh
  1547.         rol        #4,D5        ; rotate upper 4 bits
  1548.         and        #7,D5        ; get Dq/Dl
  1549.         cmp        D0,D5    ; check if they are the same register
  1550.         beq.s        10$
  1551.  
  1552.         bsr        Dreg            ; copy Dr/Dh register
  1553.         bsr        DColon            ; copy a colon
  1554. 10$:        move        D5,D0
  1555.         bra        Dreg            ; copy Dq/Dl register
  1556.  
  1557.         SYMBOL        movem_instruction
  1558. movem_instruction
  1559.         btst        #7,D1        ; check for LONG form math
  1560.         beq.s        lmath_instructions
  1561.  
  1562.         lea        movem_string,A1
  1563.         bsr        DString
  1564.  
  1565.         lea        l_string,A1
  1566.         moveq        #8,D2        ; size = long
  1567.         btst        #6,D1        ; check size bit
  1568.         bne.s        10$
  1569.         lea        w_string,A1
  1570.         moveq        #4,D2        ; size = word
  1571. 10$        bsr        DString
  1572.         bsr        DTab
  1573.         btst        #10,D1    ; direction bit
  1574.         beq.s        to_memory
  1575.         ; memory to registers
  1576.     bsr    FetchWord
  1577.     move.l    D0,-(sp)
  1578.         bsr        EA
  1579.         bsr        EffectiveAddress
  1580.         bsr        DComma
  1581.     move.l    (sp)+,D0
  1582.         bra.s        register_mask
  1583.  
  1584.         SYMBOL        to_memory
  1585. to_memory
  1586.     bsr    FetchWord
  1587. ; flip mask
  1588.     move.l    d1,-(sp)
  1589.     move.w    D0,D5
  1590.     moveq    #16-1,d1
  1591. 11$
  1592.     lsr.w    #1,D5
  1593.     addx.w    D0,D0
  1594.     dbra    d1,11$
  1595.     move.l    (sp)+,d1
  1596.  
  1597.         bsr        register_mask
  1598.         bsr        DComma
  1599.         bsr        EA
  1600.         bsr        EffectiveAddress
  1601.         rts
  1602.  
  1603. ********************* (WARNING: icky logic ahead)
  1604.         SYMBOL        register_mask
  1605. register_mask
  1606. * D0 = mask
  1607.     move.l    d1,-(sp)
  1608.  
  1609.     swap    D0
  1610.     move.w    #1,D0
  1611.     swap    D0
  1612.     moveq    #-1,D5        ; D5 = bit counter
  1613. 1$
  1614.     addq.w    #1,D5
  1615. 11$
  1616.     cmp.w    #15,D5
  1617.     bgt    90$
  1618.     btst    D5,D0    ; test mask bit
  1619.     beq    1$
  1620. ; do a reg
  1621.     moveq    #'D',d1
  1622.     btst    #3,D5        ; test Address or Data reg
  1623.     beq    2$
  1624.     moveq    #'A',d1
  1625. 2$
  1626.     move.b    d1,(A6)+        ; write reg type
  1627.     move.b    D5,d1        ; write reg number
  1628.     andi.b    #7,d1            ;
  1629.     ori.b    #'0',d1                 ;
  1630.     move.b    d1,(A6)+        ;
  1631.     cmp.w    #15,D5
  1632.     beq    90$
  1633. ; range?
  1634.     move.w    D5,d1        ; check adjacent bit
  1635.     addq.w    #1,d1
  1636.     btst    d1,D0
  1637.     bne    5$
  1638.     move.b    #'/',(A6)+          ; write separator
  1639.     bra    1$
  1640. 5$ ; do range
  1641.     move.b    #'-',(A6)+          ; write separator
  1642. 3$
  1643.     addq.w    #1,D5
  1644.     btst    D5,D0
  1645.     bne    3$
  1646.     subq.w    #1,D5
  1647.     cmp.w    #15,D5
  1648.     ble    11$
  1649.     moveq    #15,D5
  1650.     bra    11$
  1651. 90$
  1652.     cmp.b    #'/',-1(A6)
  1653.     bne    99$
  1654.     sub.l    #1,A6        ; backup over last "/"
  1655. 99$
  1656.     sf    (A6)
  1657.     move.l    (sp)+,d1
  1658.     rts
  1659.  
  1660.  IFNE 0
  1661.         SYMBOL        rmask_table
  1662. rmask_table
  1663.         dc.l        a7_string,a6_string,a5_string,a4_string
  1664.         dc.l        a3_string,a2_string,a1_string,a0_string
  1665.         dc.l        d7_string,d6_string,d5_string,d4_string
  1666.         dc.l        d3_string,d2_string,d1_string,d0_string
  1667.  
  1668.         SYMBOL        register_mask
  1669. register_mask
  1670.         bsr        FetchWord        ; get register mask
  1671.         movem.l     D3-D7/A5,-(sp)        ; save regs
  1672.         move.w        D0,d3        ; save it
  1673.         lea        rmask_table,a5
  1674.  
  1675.         move.w        D1,D0    ; instruction word
  1676.         and.b        #$38,D0
  1677.  
  1678.         moveq        #0,d6            ; bit #
  1679.         moveq        #1,d5            ; bit # increment
  1680.  
  1681.         cmp.b        #$20,D0
  1682.         beq.s        10$
  1683.  
  1684.         moveq        #15,d6            ; bit #
  1685.         moveq        #-1,d5            ; bit # increment
  1686.  
  1687. 10$        moveq        #15,D7            ; bit counter
  1688.         moveq        #0,d4            ; flag: !0 = put / first
  1689. 20$        btst        d6,d3            ; bit in mask set?
  1690.         beq.s        40$            ; if not
  1691.         tst.b        d4
  1692.         beq.s        30$            ; don't put / first
  1693.         bsr        DSlash
  1694. 30$        st        d4
  1695.         move.w        d6,D0
  1696.         asl.w        #2,D0
  1697.         move.l        (A5,D0.w),A1
  1698.         bsr        DString
  1699. 40$        add.w        d5,d6            ; add increment to bit #
  1700.         dbra        D7,20$            ; do all bits
  1701.         movem.l     (sp)+,D3-D7/A5
  1702.         rts
  1703.     ENDC
  1704.  
  1705.         SYMBOL        trap_instructions
  1706. trap_instructions
  1707.         btst        #7,D1
  1708.         bne.s        jsr_instruction
  1709.         move.w        D1,D0    ; instruction word
  1710.         asr.w        #3,D0
  1711.         and.w        #7,D0
  1712.         lea        TrapTable,A1
  1713.         bra        JumpTable
  1714.  
  1715.         SYMBOL        jsr_instruction
  1716. jsr_instruction
  1717.         btst        #6,D1
  1718.         bne.s        jmp_instruction
  1719.         lea        jsr_string,A1
  1720.         bsr        DString
  1721.         bsr        DTab
  1722.         moveq        #8,D2        ; size = long
  1723.         bra        JustEA
  1724.  
  1725.         SYMBOL        jmp_instruction
  1726. jmp_instruction
  1727.         lea        jmp_string,A1
  1728.         bsr        DString
  1729.         bsr        DTab
  1730.         moveq        #8,D2
  1731.         bra        JustEA
  1732.  
  1733.         SYMBOL        chk_instruction
  1734. chk_instruction
  1735.         btst        #6,D1
  1736.         bne.s        lea_instruction
  1737.         lea        chk_string,A1
  1738.         bsr        DString
  1739.         moveq        #4,D2        ; size = word
  1740.         btst        #7,D1        ; check the size
  1741.         bne.s        10$            ; true WORD size
  1742.         moveq        #8,D2        ; size = LONG
  1743.         lea        l_string(PC),A1        ; copy a .L for the instruction
  1744.         bsr        DString
  1745. 10$:
  1746.         bsr        DTab
  1747.         bsr        EA
  1748.         bsr        EffectiveAddress
  1749.         bsr        DComma
  1750.         bra        dreg911
  1751.  
  1752.         SYMBOL        lea_instruction
  1753. lea_instruction
  1754.         lea        lea_string,A1
  1755.         bsr        DString
  1756.         bsr        DTab
  1757.         moveq        #4,D2
  1758.         bsr        EA
  1759.         bsr        EffectiveAddress
  1760.         bsr        DComma
  1761.         bsr        DA
  1762.         bra        reg911
  1763.  
  1764.         SYMBOL        trap_instruction
  1765. trap_instruction
  1766.         lea        trap_string,A1
  1767.         bsr        DString
  1768.         bsr        DTab
  1769.         move.w        D1,D0
  1770.         and.w        #15,D0
  1771.         bra        DByte
  1772.  
  1773.         SYMBOL        unlk_instruction
  1774. unlk_instruction
  1775.         lea        unlk_string,A1
  1776.         bsr        DString
  1777.         bsr        DTab
  1778.         bsr        DA
  1779.         move.w        D1,D0
  1780.         and.w        #7,D0
  1781.         bra        DHex
  1782.  
  1783.         SYMBOL        to_usp_instruction
  1784. to_usp_instruction
  1785.         bsr        DMove
  1786.         lea        l_string,A1
  1787.         bsr        DString
  1788.         bsr        DTab
  1789.         bsr        DA
  1790.         move.w        D1,D0
  1791.         and.w        #7,D0
  1792.         bsr        DHex
  1793.         bsr        DComma
  1794.         lea        usp_string,A1
  1795.         bra        DString
  1796.  
  1797.         SYMBOL        from_usp_instruction
  1798. from_usp_instruction
  1799.         bsr        DMove
  1800.         lea        l_string,A1
  1801.         bsr        DString
  1802.         bsr        DTab
  1803.         lea        usp_string,A1
  1804.         bsr        DString
  1805.         bsr        DComma
  1806.         bsr        DA
  1807.         move.w        D1,D0
  1808.         and.w        #7,D0
  1809.         bra        DHex
  1810.  
  1811.         SYMBOL        reset_instructions
  1812. reset_instructions
  1813.         lea        ResetTable,A1
  1814.         move.w        D1,D0
  1815.         and.w        #7,D0
  1816.         bra        JumpTable
  1817.  
  1818.         SYMBOL        reset_instruction
  1819. reset_instruction
  1820.         lea        reset_string,A1
  1821.         bra        DString
  1822.  
  1823.         SYMBOL        nop_instruction
  1824. nop_instruction
  1825.         lea        nop_string,A1
  1826.         bra        DString
  1827.  
  1828.         SYMBOL        stop_instruction
  1829. stop_instruction
  1830.         lea        stop_string,A1
  1831.         bsr        DString
  1832.         bsr        DTab
  1833.         bsr        FetchWord
  1834.         bsr        DImmediate
  1835.         bra        DWord
  1836.  
  1837.         SYMBOL        rte_instruction
  1838. rte_instruction
  1839.         lea        rte_string,A1
  1840.         bra        DString
  1841.  
  1842.         SYMBOL        rts_instruction
  1843. rts_instruction
  1844.         lea        rts_string,A1
  1845.         bra        DString
  1846.  
  1847.         SYMBOL        rtd_instruction
  1848. rtd_instruction:
  1849.         lea        rtd_string(PC),A1      ; copy the instruction
  1850.         bsr        DString
  1851.         moveq        #4,D2        ; size = WORD
  1852.         bra        ImmediateData        ; copy the immediate data
  1853.  
  1854.         SYMBOL        trapv_instruction
  1855. trapv_instruction
  1856.         lea        trapv_string,A1
  1857.         bra        DString
  1858.  
  1859.         SYMBOL        rtr_instruction
  1860. rtr_instruction
  1861.         lea        rtr_string,A1
  1862.         bra        DString
  1863.  
  1864.         SYMBOL        MovecTable
  1865. MovecTable:    DC.L        spc_string,dfc_string,cacr_string,tc_string
  1866.         DC.L        itt0_string,itt1_string,dtt0_string,dtt1_string
  1867.         DC.L        usp_string,vbr_string,caar_string,msp_string
  1868.         DC.L        isp_string,mmusr_string,urp_string,srp_string
  1869.  
  1870.         SYMBOL        movec_instruction
  1871. movec_instruction:
  1872.         lea        movec_string(PC),A1    ; copy the instruction
  1873.         bsr        DString
  1874.         bsr        DTab            ; move to the next column
  1875.  
  1876.         bsr        FetchWord        ; get the extension WORD
  1877.         move        D0,D5
  1878.         and        #7,D0        ; keep control register low bits
  1879.         btst        #11,D5        ; check if high bit was set
  1880.         beq.s        10$
  1881.         addq        #8,D0        ; skip over first 8 entries
  1882. 10$:        lsl        #2,D0        ; get index * 4
  1883.         move.l        MovecTable(PC,D0),A1
  1884.  
  1885.         btst        #0,D1        ; check which direction
  1886.         beq.s        20$            ; MOVEC Rc,Rn
  1887.         bsr        dareg_operand        ; copy the register
  1888.         bsr        DComma            ; copy a comma
  1889.         bsr        DString         ; copy the control register
  1890.  
  1891. 20$:        bsr        DString         ; copy the control register
  1892.         bsr        DComma            ; copy a comma
  1893.         bra        dareg_operand        ; copy the register
  1894.  
  1895.  
  1896.         SYMBOL        MiscTable
  1897. MiscTable    dc.l        negx_instruction    ; 000
  1898.         dc.l        clr_instruction     ; 001
  1899.         dc.l        neg_instruction     ; 010
  1900.         dc.l        not_instruction     ; 011
  1901.         dc.l        nbcd_instruction    ; 100
  1902.         dc.l        tst_instruction     ; 101
  1903.         dc.l        movem_instruction    ; 110
  1904.         dc.l        trap_instructions    ; 111
  1905.  
  1906.         SYMBOL        TrapTable
  1907. TrapTable    dc.l        trap_instruction    ; 000
  1908.         dc.l        trap_instruction    ; 001
  1909.         dc.l        link_instruction    ; 010
  1910.         dc.l        unlk_instruction    ; 011
  1911.         dc.l        to_usp_instruction    ; 100
  1912.         dc.l        from_usp_instruction    ; 101
  1913.         dc.l        reset_instructions    ; 110
  1914.         dc.l        movec_instruction    ; 111
  1915.  
  1916.         SYMBOL        ResetTable
  1917. ResetTable    dc.l        reset_instruction    ; 000
  1918.         dc.l        nop_instruction     ; 001
  1919.         dc.l        stop_instruction    ; 010
  1920.         dc.l        rte_instruction     ; 011
  1921.         dc.l        rtd_instruction     ; 100
  1922.         dc.l        rts_instruction     ; 101
  1923.         dc.l        trapv_instruction    ; 110
  1924.         dc.l        rtr_instruction     ; 111
  1925.  
  1926.         SYMBOL        Group4
  1927. Group4
  1928.         btst        #8,D1
  1929.         bne        chk_instruction
  1930.  
  1931.         lea        MiscTable,A1
  1932.         move.w        D1,D0
  1933.         rol        #7,D0
  1934.         and.w        #7,D0
  1935.         bra        JumpTable
  1936.  
  1937.  
  1938. **** add quick, subtract quick, set conditionally, decrement instructions
  1939.  
  1940.         SYMBOL        ConditionTable
  1941. ConditionTable
  1942.         dc.b        "T F HILSCCCLNEEQVCVSPLMIGELTGTLE"
  1943.         SYMBOL        BConditionTable
  1944. BConditionTable
  1945.         dc.b        "RA??HILSHSLONEEQVCVSPLMIGELTGTLE"
  1946.  
  1947.         SYMBOL        DBCondition
  1948. DBCondition
  1949.         lea        BConditionTable,A1
  1950.         bra.s        DC_entry
  1951.  
  1952.         SYMBOL        DCondition
  1953. DCondition
  1954.         lea        ConditionTable,A1
  1955.         SYMBOL        DC_entry
  1956. DC_entry    move.w        D1,D0
  1957.         asr.w        #8,D0
  1958.         and.w        #$000f,D0
  1959.         add.w        D0,D0        ; 2 bytes/entry
  1960.         move.b        0(A1,D0.w),(A6)+
  1961.         cmp.b        #' ',1(A1,D0.w)
  1962.         beq.s        99$
  1963.         move.b        1(A1,D0.w),(A6)+
  1964. 99$        clr.b        (A6)
  1965.         rts
  1966.  
  1967.  
  1968.         SYMBOL        Group5
  1969. Group5
  1970.         bsr        test67
  1971.         beq.s        set_instruction
  1972.         btst        #8,D1
  1973.         bne.s        subq_instruction
  1974.  
  1975.         SYMBOL        addq_instruction
  1976. addq_instruction
  1977.         lea        addq_string,A1
  1978.  
  1979.         SYMBOL        addq_finish
  1980. addq_finish
  1981.         bsr        DString
  1982.         bsr        Size67
  1983.         bsr        DImmediate
  1984.         move.w        D1,D0        ; instruction word
  1985.         rol        #7,D0
  1986.         and.w        #7,D0
  1987.         bne.s        10$
  1988.         moveq        #8,D0
  1989. 10$        bsr        DByte
  1990.         bsr        DComma
  1991.         bsr        EA
  1992.         bsr        EffectiveAddress
  1993.         rts
  1994.  
  1995.         SYMBOL        subq_instruction
  1996. subq_instruction
  1997.         lea        subq_string,A1
  1998.         bra.s        addq_finish
  1999.  
  2000.         SYMBOL        set_instruction
  2001. set_instruction
  2002.         move.w        D1,D0
  2003.         and.w        #$38,D0
  2004.         cmp.w        #8,D0
  2005.         beq.s        dbxx_instruction
  2006.         cmp        #$38,D0     ; check for TRAPcc instruction
  2007.         bne.s        10$
  2008.         move        D1,D0
  2009.         and        #7,D0        ; get the register/opmode
  2010.         cmp        #1,D0        ; check if it is a Scc one
  2011.         bgt.s        trapxx_instruction
  2012.  
  2013. 10$:        bsr        DS
  2014.         bsr        DCondition
  2015.         bsr        DTab
  2016.         bsr        EA
  2017.         bsr        EffectiveAddress
  2018.         rts
  2019.  
  2020.         SYMBOL        dbxx_instruction
  2021. dbxx_instruction
  2022.         lea        db_string,A1
  2023.         bsr        DString
  2024.         bsr        DCondition
  2025.     cmp.b    #'F',-1(A6)
  2026.     bne.s    10$
  2027.     move.b    #'R',-1(A6)
  2028.     move.b    #'A',(A6)+
  2029.     sf    (A6)
  2030. 10$        bsr        DTab
  2031.         bsr        DD
  2032.         move.w        D1,D0
  2033.         and.w        #7,D0
  2034.         bsr        DHex
  2035.         bsr        DComma
  2036.         bsr        FetchWord
  2037.         ext.l        D0
  2038.         add.l        D7,D0
  2039.         add.l        #2,D0
  2040.         bra        DLong
  2041.  
  2042.         SYMBOL        trapxx_instruction
  2043. trapxx_instruction:
  2044.         lea        trap_string(PC),A1    ; copy the instruction
  2045.         bsr        DString
  2046.         bsr        DCondition        ; copy the condition codes
  2047.         move        D1,D0
  2048.         and        #7,D0        ; get the operand size
  2049.         cmp        #4,D0        ; check for any operand
  2050.         beq.s        10$            ; no operand for this instruction
  2051.         lea        w_string(PC),A1 ; get a ".W" size extension
  2052.         cmp        #3,D0        ; check for LONG operand
  2053.         beq.s        20$
  2054.         cmp        #2,D0        ; make sure not invalid
  2055.         bne        invalid_instruction
  2056.  
  2057.         bsr        DString         ; copy the ".W" extension
  2058.         bsr        DTab            ; move to the next column
  2059.         moveq        #4,D2        ; size = WORD
  2060.         bra        ImmediateData        ; copy the immediate data
  2061. 10$:        rts
  2062.  
  2063. 20$:        lea        l_string(PC),A1 ; copy a ".L" size extension
  2064.         bsr        DString
  2065.         bsr        DTab            ; move to the next column
  2066.         moveq        #8,D2        ; size = LONG
  2067.         bra        ImmediateData        ; copy the immediate data
  2068.  
  2069.  
  2070. **** Conditional Branch Instructions
  2071.  
  2072.  
  2073.         SYMBOL        Group6
  2074. Group6
  2075.         move.w        D1,D0
  2076.         and.w        #$0f00,D0
  2077.         cmp.w        #$0100,D0
  2078.         beq.s        bsr_instruction
  2079.  
  2080.         SYMBOL        bxx_instruction
  2081. bxx_instruction
  2082.         bsr        DB
  2083.         bsr        DBCondition
  2084.  
  2085.         SYMBOL        bxx_finish
  2086. bxx_finish
  2087.         move.b        D1,D0
  2088.         beq.s        10$            ; size = WORD
  2089.         cmp.b        #$ff,D0     ; check for LONG instruction
  2090.         bne.s        20$            ; size = BYTE
  2091.  
  2092.         lea        l_string(PC),A1        ; copy a .L for the instruction
  2093.         bsr        DString
  2094.         bsr        FetchLong        ; get a LONGWORD
  2095.         bra.s        40$
  2096. 10$:        bsr        FetchWord        ; get a WORD
  2097.         bra.s        30$
  2098. 20$:        ext        D0        ; make into a WORD
  2099.         lea        s_string(PC),A1        ; copy a .S for the instruction
  2100.         bsr        DString
  2101. 30$:        ext.l        D0        ; make into a LONGWORD
  2102. 40$:        bsr        DTab            ; move to the next column
  2103.         add.l        D7,D0
  2104.         addq        #2,D0
  2105.         bra        DLong
  2106.  
  2107.         SYMBOL        bsr_instruction
  2108. bsr_instruction
  2109.         lea        bsr_string,A1
  2110.         bsr        DString
  2111.         bra.s        bxx_finish
  2112.  
  2113. **** MOVE QUICK instruction
  2114.  
  2115.  
  2116.         SYMBOL        Group7
  2117. Group7
  2118.         btst        #8,D1
  2119.         bne        invalid_instruction
  2120.  
  2121.         lea        moveq_string,A1
  2122.         bsr        DString
  2123.         bsr        DTab
  2124.         bsr        DImmediate
  2125.         move.b        D1,D0
  2126.         bsr        DByte
  2127.         bsr        DComma
  2128.         bra        dreg911
  2129.  
  2130. **** OR, DIVIDE, SUBTRACT DECIMAL instructions
  2131.  
  2132.  
  2133. ; 831e should be or.b d1,(a6)+ is sbcd -(a6),-(a1)
  2134. ; *** This is now fixed [BSB 18-June-92]
  2135.  
  2136.         SYMBOL        OrTable
  2137. OrTable:
  2138.         dc.l        or_instruction        ; bits 8-6 000
  2139.         dc.l        or_instruction        ;       001
  2140.         dc.l        or_instruction        ;       010
  2141.         dc.l        divu_instruction    ;       011
  2142.         dc.l        sbcd_instruction    ;       100
  2143.         dc.l        pack_instruction    ;       101
  2144.         dc.l        unpk_instruction    ;       110
  2145.         dc.l        divs_instruction    ;       111
  2146.  
  2147.         SYMBOL        Group8
  2148. Group8
  2149.         move.w        D1,D0
  2150.         and.w        #$01c0,D0
  2151.         lsr        #4,D0        ; adjust table index
  2152.         lea        OrTable(PC),A1        ; get Group8 table
  2153.         bra        ScaledJumpTable     ; call Group8 routine
  2154.  
  2155.         SYMBOL        or_instruction
  2156. or_instruction
  2157.         lea        or_string,A1
  2158.  
  2159.         SYMBOL        or_finish
  2160. or_finish
  2161.         bsr        DString
  2162.         bsr        Size67
  2163.         btst        #8,D1
  2164.         bne.s        10$            ; dn,ea
  2165.         ; ea,dn
  2166.         bsr        EA
  2167.         bsr        EffectiveAddress
  2168.         bsr        DComma
  2169.         bra        dreg911
  2170.  
  2171. 10$        bsr        dreg911
  2172.         bsr        DComma
  2173.         bsr        EA
  2174.         bsr        EffectiveAddress
  2175.         rts
  2176.  
  2177.  
  2178.         SYMBOL        divu_instruction
  2179. divu_instruction
  2180.         lea        divu_string,A1
  2181.  
  2182.         SYMBOL        divu_finish
  2183. divu_finish
  2184.         bsr        DString
  2185.         bsr        DTab
  2186.         bsr        EA
  2187.         bsr        EffectiveAddress
  2188.         bsr        DComma
  2189.         bra        dreg911
  2190.  
  2191.  
  2192.         SYMBOL        divs_instruction
  2193. divs_instruction
  2194.         lea        divs_string,A1
  2195.         bra.s        divu_finish
  2196.  
  2197.         SYMBOL        sbcd_instruction
  2198. sbcd_instruction
  2199.         move        D1,D0    ; get the instruction
  2200.         and        #$0030,D0        ; keep bits 5-4
  2201.         bne.s        or_instruction        ; must be OR.B instruction
  2202.  
  2203.         lea        sbcd_string,A1
  2204.         bsr        DString
  2205.         bsr        DTab
  2206.  
  2207.         SYMBOL        sbcd_finish
  2208. sbcd_finish
  2209.         btst        #3,D1
  2210.         beq.s        both_registers    ; if register to register
  2211.  
  2212.         SYMBOL        both_predecrements
  2213. both_predecrements:
  2214.         bsr        DMinus
  2215.         bsr        DOpen
  2216.         bsr        DA
  2217.         move.w        D1,D0
  2218.         and.w        #7,D0
  2219.         bsr        DHex
  2220.         bsr        DClose
  2221.  
  2222.         bsr        DComma
  2223.  
  2224.         bsr        DMinus
  2225.         bsr        DOpen
  2226.         bsr        DA
  2227.         bsr        reg911
  2228.         bra        DClose
  2229.  
  2230.         SYMBOL        both_registers
  2231. both_registers:
  2232.         bsr        DD
  2233.         move.w        D1,D0
  2234.         and.w        #7,D0
  2235.         bsr        DHex
  2236.         bsr        DComma
  2237.         bra        dreg911
  2238.  
  2239.  
  2240.         SYMBOL        unpk_instruction
  2241. unpk_instruction:
  2242.         lea        unpk_string(PC),A1    ; copy the command
  2243.         bra.s        pack_finish
  2244.  
  2245.  
  2246.         SYMBOL        pack_instruction
  2247. pack_instruction:
  2248.         lea        pack_string(PC),A1    ; copy the command
  2249.  
  2250.         SYMBOL        pack_finish
  2251. pack_finish:
  2252.         move        D1,D0    ; get the instruction
  2253.         and        #$0030,D0        ; keep bits 5-4
  2254.         bne        or_instruction        ; must be OR.B instruction
  2255.  
  2256.         bsr        DString
  2257.         bsr        DTab            ; move to the next column
  2258.         btst        #3,D1        ; check if registers
  2259.         beq.s        10$            ; register to register
  2260.         bsr        both_predecrements    ; -(An),-(An)
  2261.         bra.s        20$
  2262. 10$:
  2263.         bsr        both_registers        ; Dn,Dn
  2264. 20$:
  2265.         bsr        DComma            ; output a comma
  2266.         moveq        #4,D2        ; immediate WORD size
  2267.         bra        ImmediateData        ; output adjustment
  2268.  
  2269.  
  2270. **** SUB, SUBX instructions
  2271.  
  2272.  
  2273.         SYMBOL        Group9
  2274. Group9:     move        D1,D0    ; check for SUBA instruction
  2275.         and        #$1c0,D0        ; keep opmode bits
  2276.         cmp        #$0c0,D0        ; check for first SUBA
  2277.         beq.s        suba_instruction
  2278.         cmp        #$1c0,D0        ; check for second SUBA
  2279.         beq.s        suba_instruction
  2280.  
  2281.         move.w        D1,D0
  2282.         and.w        #$130,D0
  2283.         cmp.w        #$0100,D0
  2284.         beq.s        subx_instruction
  2285.  
  2286.         SYMBOL        sub_instruction
  2287. sub_instruction
  2288.         lea        sub_string,A1
  2289.         bra        or_finish
  2290.  
  2291.         SYMBOL        suba_instruction
  2292. suba_instruction:
  2293.         lea        suba_string(PC),A1    ; copy the instruction
  2294.         bra        address_operand
  2295.  
  2296.         SYMBOL        subx_instruction
  2297. subx_instruction
  2298.         lea        subx_string,A1
  2299.         bsr        DString
  2300.         bsr        Size67
  2301.         bra        sbcd_finish
  2302.  
  2303. **** LINE A instructions
  2304.  
  2305.  
  2306.         SYMBOL        Group10
  2307. Group10
  2308.         moveq        #2,D6
  2309.         lea        dcw_string,A1
  2310.         bsr        DString
  2311.         bsr        DTab
  2312.         moveq        #0,D0
  2313.         move.w        D1,D0
  2314.         bsr        DWord
  2315.         bsr        DTab
  2316.         lea        aline_string,A1
  2317.         bra        DString
  2318.  
  2319.  
  2320. **** CMP, CMPM, EOR instructions
  2321.  
  2322.  
  2323.         SYMBOL        GROUP11_TABLE
  2324. GROUP11_TABLE    dc.l        cmp_instruction
  2325.         dc.l        cmp_instruction
  2326.         dc.l        cmp_instruction
  2327.         dc.l        cmpa_instruction
  2328.         dc.l        cmpm_instruction
  2329.         dc.l        cmpm_instruction
  2330.         dc.l        cmpm_instruction
  2331.         dc.l        cmpa_instruction
  2332.  
  2333. ; b501 should be eor.b d2,d1 is cmpm.b (a1)+,(a2)+
  2334. ; *** This is now fixed [BSB 18-June-92]
  2335.  
  2336.         SYMBOL        Group11
  2337. Group11
  2338.         move.w        D1,D0
  2339.         asr.w        #6,D0
  2340.         and.w        #7,D0
  2341.         lea        GROUP11_TABLE(pc),A1
  2342.         bra        JumpTable
  2343.  
  2344.         SYMBOL        cmpa_instruction
  2345. cmpa_instruction
  2346.         move        D1,D0    ; get the instruction
  2347.         and        #$01c0,D0        ; keep the opmode
  2348.         cmp        #$0100,D0        ; check for EOR.B
  2349.         beq        eor_instruction
  2350.  
  2351.         lea        cmpa_string,A1
  2352.         bsr        DString
  2353.         move.w        #%1111111001111111,D0 ; bit67 = 01
  2354.         btst        #8,D1
  2355.         beq.s        10$
  2356.         move.w        #%1111111010111111,D0 ; bit67 = 10
  2357. 10$        and.w        D0,D1
  2358.         bsr        Size67
  2359.         bsr        EA
  2360.         bsr        EffectiveAddress
  2361.         bsr        DComma
  2362.         bra        areg911
  2363.  
  2364.         SYMBOL        cmpm_instruction
  2365. cmpm_instruction
  2366.         move.w        D1,D0
  2367.         and.w        #$38,D0
  2368.         cmp.w        #$08,D0
  2369.         bne.s        eor_instruction
  2370.  
  2371.         lea        cmpm_string,A1
  2372.         bsr        DString
  2373.         bsr        Size67
  2374.         bsr        DOpen
  2375.         bsr        DA
  2376.         move.w        D1,D0
  2377.         and.w        #7,D0
  2378.         bsr        DHex
  2379.         bsr        DClose
  2380.         bsr        DPlus
  2381.         bsr        DComma
  2382.         bsr        DOpen
  2383.         bsr        DA
  2384.         bsr        reg911
  2385.         bsr        DClose
  2386.         bra        DPlus
  2387.  
  2388.         SYMBOL        cmp_instruction
  2389. cmp_instruction
  2390.         lea        cmp_string,A1
  2391.         bsr        DString
  2392.         bsr        Size67
  2393.         bsr        EA
  2394.         bsr        EffectiveAddress
  2395.         bsr        DComma
  2396.         bra        dreg911
  2397.  
  2398.         SYMBOL        eor_instruction
  2399. eor_instruction
  2400.         lea        eor_string,A1
  2401.         bra        or_finish
  2402.  
  2403. **** AND, MULTIPLY, EXG, ABCD instructions
  2404.  
  2405.  
  2406.         SYMBOL        Group12
  2407. Group12
  2408.         move.w        D1,D0
  2409.         and.w        #$01c0,D0
  2410.         cmp.w        #$01c0,D0
  2411.         beq.s        muls_instruction
  2412.         cmp.w        #$00c0,D0
  2413.         beq.s        mulu_instruction
  2414.  
  2415.         move.w        D1,D0
  2416.         and.w        #$01f8,D0
  2417.         cmp.w        #$0188,D0
  2418.         beq.s        exgm_instruction
  2419.         cmp.w        #$0148,D0
  2420.         beq.s        exga_instruction
  2421.         cmp.w        #$140,D0
  2422.         beq.s        exgd_instruction
  2423.  
  2424.         and.w        #$01f0,D0
  2425.         cmp.w        #$0100,D0
  2426.         beq.s        abcd_instruction
  2427.  
  2428.  
  2429.         SYMBOL        and_instruction
  2430. and_instruction
  2431.         lea        and_string,A1
  2432.         bra        or_finish
  2433.  
  2434.         SYMBOL        muls_instruction
  2435. muls_instruction
  2436.         lea        muls_string,A1
  2437.         bra        divu_finish
  2438.  
  2439.         SYMBOL        mulu_instruction
  2440. mulu_instruction
  2441.         lea        mulu_string,A1
  2442.         bra        divu_finish
  2443.  
  2444.         SYMBOL        dexg
  2445. dexg        lea        exg_string,A1
  2446.         bsr        DString
  2447.         bra        DTab
  2448.  
  2449.  
  2450.         SYMBOL        exgm_instruction
  2451. exgm_instruction
  2452.         bsr        dexg
  2453.         bsr        dreg911
  2454.         bsr        DComma
  2455.         bra        areg02
  2456.  
  2457.         SYMBOL        exga_instruction
  2458. exga_instruction
  2459.         bsr        dexg
  2460.         bsr        areg911
  2461.         bsr        DComma
  2462.         bra        areg02
  2463.  
  2464.         SYMBOL        exgd_instruction
  2465. exgd_instruction
  2466.         bsr        dexg
  2467.         bsr        dreg911
  2468.         bsr        DComma
  2469.         bra        dreg02
  2470.  
  2471.         SYMBOL        abcd_instruction
  2472. abcd_instruction
  2473.         lea        abcd_string,A1
  2474.         bra        sbcd_finish
  2475.  
  2476.  
  2477. **** ADD, ADDX instructions
  2478.  
  2479.  
  2480.         SYMBOL        Group13
  2481. Group13
  2482.         move.w        D1,D0
  2483.         and.w        #$1c0,D0
  2484.         cmp.w        #$c0,D0
  2485.         beq.s        adda_instruction
  2486.         cmp.w        #$1c0,D0
  2487.         beq.s        adda_instruction
  2488.         ; determine addx or add...
  2489.         move.w        D1,D0
  2490.         and.w        #$0130,D0
  2491.         cmp.w        #$0100,D0
  2492.         beq.s        addx_instruction
  2493.  
  2494.         SYMBOL        add_instruction
  2495. add_instruction
  2496.         lea        add_string,A1
  2497.         bra        or_finish
  2498.  
  2499.         SYMBOL        adda_instruction
  2500. adda_instruction
  2501.         lea        adda_string,A1
  2502.  
  2503.         SYMBOL        address_operand
  2504. address_operand:
  2505.         bsr        DString
  2506.         lea        w_string,A1
  2507.         move.l        #4,D2
  2508.         btst        #8,D1
  2509.         beq.s        10$
  2510.         lea        l_string,A1
  2511.         move.l        #8,D2
  2512. 10$        bsr        DString
  2513.         bsr        DTab
  2514.         bsr        EA        ; MUST BE BSR THEN RTS:
  2515.         bsr        EffectiveAddress
  2516.         bsr        DComma
  2517.         bsr        DA
  2518.         move.w        D1,D0
  2519.         asr.w        #8,D0
  2520.         asr.w        #1,D0
  2521.         and.w        #7,D0
  2522.         bra        DHex
  2523.  
  2524.         SYMBOL        addx_instruction
  2525. addx_instruction
  2526.         lea        addx_string,A1
  2527.         bsr        DString
  2528.         bsr        Size67
  2529.         bra        sbcd_finish
  2530.  
  2531. **** Shift/Rotate/Bit Field instructions
  2532.  
  2533.         SYMBOL        ShiftTable
  2534. ShiftTable    dc.l        asr_string,lsr_string,roxr_string,ror_string
  2535.         dc.l        asl_string,lsl_string,roxl_string,rol_string
  2536.  
  2537.         SYMBOL        dshift
  2538. dshift
  2539.         lea        ShiftTable,A1
  2540.         btst        #8,D1
  2541.         beq.s        10$
  2542.         addq.w        #4,D0
  2543. 10$        asl.w        #2,D0
  2544.         move.l        0(A1,D0.w),A1
  2545.         bra        DString
  2546. ;        bra        DTab
  2547.  
  2548.  
  2549.         SYMBOL        Group14
  2550. Group14
  2551.         bsr        test67
  2552.         beq.s        memory_field
  2553.  
  2554.         SYMBOL        register_shift
  2555. register_shift
  2556.         move.w        D1,D0
  2557.         asr.w        #3,D0
  2558.         and.w        #3,D0
  2559.         bsr        dshift
  2560.         bsr        Size67
  2561. ;        bsr        DTab
  2562.         btst        #5,D1
  2563.         beq.s        10$
  2564.         bsr        dreg911
  2565.         bsr        DComma
  2566.         bra        dreg02
  2567. 10$        bsr        DImmediate
  2568.         move.w        D1,D0
  2569.         rol        #7,d0
  2570.         and.w        #7,d0
  2571.         bne.s        20$
  2572.         moveq        #8,d0
  2573. 20$        bsr        DHex
  2574.         bsr        DComma
  2575.         bra        dreg02
  2576.  
  2577.         SYMBOL        BitfieldTable
  2578. BitfieldTable:    DC.L        bftst_string,bfextu_string,bfchg_string,bfexts_string
  2579.         DC.L        bfclr_string,bfffo_string,bfset_string,bfins_string
  2580.  
  2581.         SYMBOL        memory_field
  2582. memory_field:
  2583.         move.w        D1,D0
  2584.         asr.w        #8,D0
  2585.         btst        #3,D0        ; check for bit field instructions
  2586.         beq        memory_shift        ; must be memory shift instruction
  2587.  
  2588. ;
  2589. ; Bit field insructions
  2590. ;
  2591.         and        #7,D0        ; keep instruction index
  2592.         lsl        #2,D0        ; make LONGWORD index
  2593.         lea        BitfieldTable(PC,D0),A1
  2594.         move.l        (A1),A1           ; get the string pointer
  2595.         bsr        DString         ; copy the string
  2596.         bsr        DTab            ; tab to the next column
  2597.  
  2598.         bsr        FetchWord        ; get the second extension WORD
  2599.         move        D0,D5
  2600.         bsr        EA            ; set the EA bits
  2601.         move        D1,D0
  2602.         lsr        #8,D0        ; keep the bit field instruction
  2603.         and        #7,D0
  2604.         btst        #0,D0        ; check type of <EA> needed
  2605.         beq.s        10$            ; only a <EA>{} is needed
  2606.         cmp        #7,D0        ; check if it is a BFINS
  2607.         bne.s        20$            ; no, needs <EA>{},Dn
  2608.  
  2609.         bsr        Scratch1Dreg1214    ; copy Dn,<EA>{OFFSET:WIDTH}
  2610.         bsr        DComma
  2611.  
  2612. ;
  2613. ; Output a <EA>{offset:width} for a instruction
  2614. ;
  2615. 10$:        bsr        EffectiveAddress
  2616.         bsr        DOpenCurly        ; copy a open curly bracket
  2617.         move        D5,D0
  2618.         lsr        #6,D0        ; get the offset
  2619.         and        #$3f,D0     ; keep only the offset
  2620.         bsr        DByte            ; copy the bit field offset
  2621.         bsr        DColon            ; copy a colon
  2622.         move        D5,D0
  2623.         and        #$3f,D0     ; keep only the width
  2624.         bsr        DByte            ; copy the bit field width
  2625.         bra        DCloseCurly        ; copy a close curly bracket
  2626.  
  2627. 20$:        bsr.s        10$            ; copy the <EA>{OFFSET:WIDTH}
  2628.         bsr        DComma            ; copy a comma
  2629.         bra        Scratch1Dreg1214    ; copy the data register
  2630.  
  2631.  
  2632.         SYMBOL        memory_shift
  2633. memory_shift:
  2634.         asr.w        #1,D0
  2635.         and.w        #3,D0
  2636.         bsr        dshift
  2637.         lea        b_string,A1
  2638.         bsr        DString
  2639. ;        bsr        DTab
  2640.         bsr        EA
  2641.         bsr        EffectiveAddress
  2642.         rts
  2643.  
  2644. **** LINE F/Coprocessor Interface instructions
  2645.  
  2646.  
  2647.         SYMBOL        Group15
  2648. Group15
  2649.         moveq        #2,D6
  2650.         lea        dcw_string,A1
  2651.         bsr        DString
  2652.         bsr        DTab
  2653.         moveq        #0,D0
  2654.         move.w        D1,D0
  2655.         bsr        DWord
  2656.         bsr        DTab
  2657.         lea        fline_string,A1
  2658.         bra        DString
  2659.  
  2660. **** Strings
  2661.  
  2662. string        MACRO
  2663.         SYMBOL        \1
  2664. \1        dc.b        \2,0
  2665.         ENDM
  2666.  
  2667.         SYMBOL        invalid_string
  2668. invalid_string    dc.b        ";",$20,"***INVALID***",0
  2669.  
  2670.         SYMBOL        aline_string
  2671. aline_string    dc.b        ";",$20,"***A-LINE***",0
  2672.  
  2673.         SYMBOL        fline_string
  2674. fline_string    dc.b        ";",$20,"***F-LINE***",0
  2675.  
  2676.         string        hex_string,"0123456789ABCDEF"
  2677.  
  2678.         string        d0_string,"D0"
  2679.         string        d1_string,"D1"
  2680.         string        d2_string,"D2"
  2681.         string        d3_string,"D3"
  2682.         string        d4_string,"D4"
  2683.         string        d5_string,"D5"
  2684.         string        d6_string,"D6"
  2685.         string        d7_string,"D7"
  2686.         string        a0_string,"A0"
  2687.         string        a1_string,"A1"
  2688.         string        a2_string,"A2"
  2689.         string        a3_string,"A3"
  2690.         string        a4_string,"A4"
  2691.         string        a5_string,"A5"
  2692.         string        a6_string,"A6"
  2693.         string        a7_string,"A7"
  2694.  
  2695.         string        dcw_string,"DC.W"
  2696.  
  2697.         string        chg_string,"CHG"
  2698.         string        set_string,"SET"
  2699.  
  2700.         string        parenbracket_string,"(["
  2701.  
  2702.         string        pcr_string,"(PC)"
  2703.         string        pc_string,"PC"
  2704.         string        ccr_string,"CCR"
  2705.         string        sr_string,"SR"
  2706.         string        usp_string,"USP"
  2707.  
  2708.         string        spc_string,"SFC"
  2709.         string        dfc_string,"DFC"
  2710.         string        vbr_string,"VBR"
  2711.         string        cacr_string,"CACR"
  2712.         string        caar_string,"CAAR"
  2713.         string        isp_string,"ISP"
  2714.         string        tc_string,"TC"
  2715.         string        itt0_string,"ITT0"
  2716.         string        itt1_string,"ITT1"
  2717.         string        dtt0_string,"DTT0"
  2718.         string        dtt1_string,"DTT1"
  2719.         string        msp_string,"MSP"
  2720.         string        mmusr_string,"MMUSR"
  2721.         string        urp_string,"URP"
  2722.         string        srp_string,"SRP"
  2723.  
  2724.         string        b_string,".B"
  2725.         string        w_string,".W"
  2726.         string        l_string,".L"
  2727.         string        s_string,".S"
  2728.  
  2729.         string        abcd_string,"ABCD"
  2730.         string        add_string,"ADD"
  2731.         string        adda_string,"ADDA"
  2732.         string        addi_string,"ADDI"
  2733.         string        addq_string,"ADDQ"
  2734.         string        addx_string,"ADDX"
  2735.         string        and_string,"AND"
  2736.         string        andi_string,"ANDI"
  2737.         string        asl_string,"ASL"
  2738.         string        asr_string,"ASR"
  2739.         string        bfchg_string,"BFCHG"
  2740.         string        bfclr_string,"BFCLR"
  2741.         string        bfexts_string,"BFEXTS"
  2742.         string        bfextu_string,"BFEXTU"
  2743.         string        bfffo_string,"BFFFO"
  2744.         string        bfins_string,"BFINS"
  2745.         string        bfset_string,"BFSET"
  2746.         string        bftst_string,"BFTST"
  2747.         string        bgnd_string,"BGND"
  2748.         string        bkpt_string,"BKPT"
  2749.         string        bsr_string,"BSR"
  2750.         string        callm_string,"CALLM"
  2751.         string        cas_string,"CAS"
  2752.         string        cas2_string,"CAS2"
  2753.         string        chk_string,"CHK"
  2754.         string        chk2_string,"CHK2"
  2755.         string        cinv_string,"CINV"
  2756.         string        clr_string,"CLR"
  2757.         string        cmp_string,"CMP"
  2758.         string        cmpa_string,"CMPA"
  2759.         string        cmpi_string,"CMPI"
  2760.         string        cmpm_string,"CMPM"
  2761.         string        cmp2_string,"CMP2"
  2762.         string        cpush_string,"CPUSH"
  2763.         string        db_string,"DB"
  2764.         string        divs_string,"DIVS"
  2765.         string        divsl_string,"DIVS.L"
  2766.         string        divsll_string,"DIVSL.L"
  2767.         string        divu_string,"DIVU"
  2768.         string        divul_string,"DIVU.L"
  2769.         string        divull_string,"DIVUL.L"
  2770.         string        eor_string,"EOR"
  2771.         string        eori_string,"EORI"
  2772.         string        exg_string,"EXG"
  2773.         string        extbl_string,"EXTB.L"
  2774.         string        extw_string,"EXT.W"
  2775.         string        extl_string,"EXT.L"
  2776.         string        illegal_string,"ILLEGAL"
  2777.         string        jmp_string,"JMP"
  2778.         string        jsr_string,"JSR"
  2779.         string        lea_string,"LEA"
  2780.         string        link_string,"LINK"
  2781.         string        lsl_string,"LSL"
  2782.         string        lsr_string,"LSR"
  2783.         string        move_string,"MOVE"
  2784.         string        move16_string,"MOVE16"
  2785.         string        movec_string,"MOVEC"
  2786.         string        movem_string,"MOVEM"
  2787.         string        movep_string,"MOVEP"
  2788.         string        moveq_string,"MOVEQ"
  2789.         string        moves_string,"MOVES"
  2790.         string        muls_string,"MULS"
  2791.         string        mulsl_string,"MULS.L"
  2792.         string        mulsll_string,"MULSL.L"
  2793.         string        mulu_string,"MULU"
  2794.         string        mulul_string,"MULU.L"
  2795.         string        mulull_string,"MULUL.L"
  2796.         string        nbcd_string,"NBCD"
  2797.         string        neg_string,"NEG"
  2798.         string        negx_string,"NEGX"
  2799.         string        nop_string,"NOP"
  2800.         string        not_string,"NOT"
  2801.         string        or_string,"OR"
  2802.         string        ori_string,"ORI"
  2803.         string        pack_string,"PACK"
  2804.         string        pea_string,"PEA"
  2805.         string        pflush_string,"PFLUSH"
  2806.         string        pflusha_string,"PFLUSHA"
  2807.         string        pload_string,"PLOAD"
  2808.         string        pmove_string,"PMOVE"
  2809.         string        ptest_string,"PTEST"
  2810.         string        reset_string,"RESET"
  2811.         string        rol_string,"ROL"
  2812.         string        ror_string,"ROR"
  2813.         string        roxl_string,"ROXL"
  2814.         string        roxr_string,"ROXR"
  2815.         string        rtd_string,"RTD"
  2816.         string        rte_string,"RTE"
  2817.         string        rtm_string,"RTM"
  2818.         string        rtr_string,"RTR"
  2819.         string        rts_string,"RTS"
  2820.         string        sbcd_string,"SBCD"
  2821.         string        stop_string,"STOP"
  2822.         string        sub_string,"SUB"
  2823.         string        suba_string,"SUBA"
  2824.         string        subi_string,"SUBI"
  2825.         string        subq_string,"SUBQ"
  2826.         string        subx_string,"SUBX"
  2827.         string        swap_string,"SWAP"
  2828.         string        tas_string,"TAS"
  2829.         string        trap_string,"TRAP"
  2830.         string        trapv_string,"TRAPV"
  2831.         string        tst_string,"TST"
  2832.         string        unlk_string,"UNLK"
  2833.         string        unpk_string,"UNPK"
  2834.  
  2835.         END
  2836.